Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I convert the FLIF image to jpeg losslessly? #544

Open
stephane-archer opened this issue Oct 29, 2019 · 8 comments
Open

Can I convert the FLIF image to jpeg losslessly? #544

stephane-archer opened this issue Oct 29, 2019 · 8 comments
Labels

Comments

@stephane-archer
Copy link

If FLIF is lossless it means that the image will be exactly the same as my jpeg right?
But Can I convert the FLIF image to jpeg losslessly?

@bjorn3
Copy link

bjorn3 commented Oct 29, 2019

Even converting jpeg to jpeg would likely cause differences in results. There are multiple ways to encode the same image data and you will have to convince the jpeg writer to not so anything lossless. Converting between FLIF and another lossless file format, for example png, would not change the image data, but those also have multiple ways to encode the same data.

Also be aware that development of FLIF has basically stopped. The last comment was 1 year ago. And several memory corruption bugs remain unfixed. For example #541.

@stephane-archer
Copy link
Author

stephane-archer commented Oct 29, 2019 via email

@zigazeljko
Copy link

If your photos are already in JPEG format, I doubt that FLIF would compress them any better.

You should probably check out Lepton (https://github.com/dropbox/lepton), which is made specifically for such cases (losslessly recompressing pre-existing JPEG files).

@Two-Tone
Copy link

I've actually transcoded a number of jpg compressed images into flif images and for most of them the flif re-encode was a few percents smaller than the original jpg.

@cherrysnower
Copy link

what is the compression rate between the jpeg file the the flif file

@cherrysnower
Copy link

I've actually transcoded a number of jpg compressed images into flif images and for most of them the flif re-encode was a few percents smaller than the original jpg.

May I ask what is the compression rate between the jpeg file and the flif file ? Another question is how can the FLIF project support the jpeg input?

@Two-Tone
Copy link

I wanna say it was between 3-5% smaller on average? This was many months ago, though, so I can't give actual numbers, just share some slightly vague memories

Another question is how can the FLIF project support the jpeg input?

This Github is just a reference encoder/decoder for the format. I had used ImageMagick to do the conversion.

@ziemek99
Copy link
Member

ziemek99 commented Jan 18, 2022

Even converting jpeg to jpeg would likely cause differences in results. There are multiple ways to encode the same image data and you will have to convince the jpeg writer to not so anything lossless. Converting between FLIF and another lossless file format, for example png, would not change the image data, but those also have multiple ways to encode the same data.

Also be aware that development of FLIF has basically stopped. The last comment was 1 year ago. And several memory corruption bugs remain unfixed. For example #541.

@bjorn3 you're right about differences in results and you're right about development being stopped. FLIF was extended to FUIF, which became part of JPEG XL. You can read more about JPEG XL on an official website, community website, dig into GitHub repository or join Jon, other JPEG XL devs and the community on a Discord server.

I've actually transcoded a number of jpg compressed images into flif images and for most of them the flif re-encode was a few percents smaller than the original jpg.

@Two-Tone JPEG XL has a unique feature that allows re-encoding JPEG to smaller files without changing the data, i.e. resulting JPEG XL file can be bit-exactly decoded back to source JPEG. Similar functionality was meant to be included in FLIF (see #209), but then JPEG XL happened and FLIF's development stopped.

If you decoded your JPEGs, re-encoded them losslessly with FLIF and then removed the originals immediately:

  • just like @bjorn3 said, you're at the mercy of JPEG decoder you chose for doing the task and you can't use better decoder (like Knusperli) in the future since DCT coefficients and quantization factors are now lost,
  • you're stuck with pixels, which are harder to compress losslessly than quantized DCT coefficients since most lossless image encoders aren't even aware of DCT transform's existence and they can't exploit any correlations that happen because of that.

I genuinely hope you still have your original JPEG files...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants