FLIF icon indicating copy to clipboard operation
FLIF copied to clipboard

Can I convert the FLIF image to jpeg losslessly?

Open stephane-archer opened this issue 4 years ago • 8 comments

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?

stephane-archer avatar Oct 29 '19 14:10 stephane-archer

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 https://github.com/FLIF-hub/FLIF/issues/541.

bjorn3 avatar Oct 29 '19 14:10 bjorn3

Thank you for this great explanation. I'm looking for something to compress my JPEG (photos from camera) losslessly. So I can store them with less space but I don't want to sacrifice the quality of these memories. Do you think FLIF is good in that case? Do you have any other recommendations?

On Tue, Oct 29, 2019, 23:48 bjorn3 [email protected] wrote:

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 https://github.com/FLIF-hub/FLIF/issues/541.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FLIF-hub/FLIF/issues/544?email_source=notifications&email_token=AAWX4PLNGBYY4R5DV2UNKZDQRBEL7A5CNFSM4JGJTGD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECQYV7A#issuecomment-547457788, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWX4PNRTUEF63UGCLN5HOTQRBEL7ANCNFSM4JGJTGDQ .

stephane-archer avatar Oct 29 '19 16:10 stephane-archer

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).

zigazeljko avatar Nov 15 '19 22:11 zigazeljko

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 avatar Dec 14 '19 11:12 Two-Tone

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

cherrysnower avatar Feb 25 '20 03:02 cherrysnower

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?

cherrysnower avatar Feb 26 '20 01:02 cherrysnower

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.

Two-Tone avatar Feb 26 '20 06:02 Two-Tone

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...

ziemek99 avatar Jan 18 '22 09:01 ziemek99