Add new comment

Image Orientation (EXIF)

Hello,

I'm using LibRaw to process RAW files on Windows. I'm using the March Snapshot built with Visual Studio 2017, 64-bit,

I'm having problems with EXIF orientation in several RAW files, mostly Canon CR2 files.
When the user enables the option to use the embedded preview in the CR2, my software uses the routines

unpack_thumb
dcraw_make_mem_thumb

to create an in-memory image and then I load that image into my image library for further processing. After loading the image my code checks the

imgdata.sizes.flip

and performs the rotation based on that this variable contains.
Apparently, this does not always work correct.

The example CR2 file has an EXIF orientation value of 270° clockwise. The imgdata.sizes.flip has the value 5 (rotate counter-clockwise by 90°) which seems to match what's in the EXIF.
However, when I perform the requested rotation, the preview comes out rotated wrong!

When I instead use

unpack
dcraw_process
...
dcraw_ppm_tiff_writer

functions and such export a TIFF file from the results (and then load that into my image library) the orientation is correct. I have learned to not apply the imgdata.sizes.flip in this case, as it seems that LibRaw does this automatically when saving the TIFF (?)

My software also processes NEF and other RAW files through LibRaw, always using the same "use preview" method, applying the rotation as requested by the imgdata.sizes.flip variable. This seems to work pretty well in general, but not always.

Is there anything I can check in the file?
Or would you need a sample CR2 file which produces this problem?

Thank you in advance.

Forums: