strukturag / libheif

libheif is an HEIF and AVIF file format decoder and encoder.
Other
1.76k stars 302 forks source link

Please provide receipt to convert raw DNG and CR2 to lossless HEIC #126

Open avibrazil opened 5 years ago

avibrazil commented 5 years ago

How to convert lossless raw photos (DNG, CR2) to lossless HEIC with the command line ? Complete, copying tags and all.

HEIC lossless compression yields to ~70% compression (HEIC size is 70% of the original file size) when compared to DNG and ~30% (HEIC size is 30% of the original file size) when compared to Canon raw CR2 formats.

https://avi.alkalay.net/2018/08/heic-lossless-images.html

Thank you

farindk commented 5 years ago

You have to take care about the word 'lossless'. In raw photos, the image is stored as the raw sensor data, which comes close (bit not quite) to RGB. It's more like a greyscale with Bayer pattern.

HEIC, however, as the standard is defined currently, only supports images stored in the YCbCr color space. I.e. any data in YCbCr space can be stored lossless, but not RGB images.

Thus, I believe it is not possible to store an exact copy of raw images in HEIC without adding proprietary extensions to HEIC.

Joilence commented 3 years ago

@farindk Thanks for the explanation. Does this mean either way if a CR2 image is converted into HEIC format, it would not have the same capability for editing as CR2 does anyway? Will it be better the JPEGs?

farindk commented 3 years ago

I don't know enough about CR2 to tell exactly what additional information is stored in there. However, as it is a raw format, I am pretty sure that it is storing raw sensor data instead of processed RGB and that it also contains lots of camera metadata. Even if that could be transferred into the HEIC, it would only be useful if your remaining software pipeline can process it like a raw image.