SharpLibraw icon indicating copy to clipboard operation
SharpLibraw copied to clipboard

How do I get at the "flip" int in libraw_image_sizes_t?

Open MikePelton opened this issue 2 years ago • 5 comments

Hi - am trying to stop libraw from rotating images which I understand can be achieved by setting the flip variable in the ...image_sizes struct to 0. However I can't see access to that struct via rawlib.cs (I may be missing something obvious of course). Alternatively if I can intercept the EXIF data being read as the file's being opened I could know the original orientation and reverse libraw's rotation in separate code, but I'm not seeing an example of how to interpret the data being passed into EXIFParserCallback(IntPtr context, int tag, int type, int len, uint ord, IntPtr ifp, long _base), specifically how do I read data off the IntPtr ifp? All help welcome - thanks!

MikePelton avatar Nov 12 '22 09:11 MikePelton

Hi! @MikePelton

That structure is not directly exposed in SharpLibraw. I will try to implement in the next version. Or you can try to do it an create a pull request.

BR,

Ladislav

laheller avatar Jan 16 '23 11:01 laheller

Hi Ladislav and thanks for coming back - we have a sub-optimal workaround, but a workaround nevertheless, which means I'm more than happy to wait for your updates - I suspect you'll do a much better job than me of marshalling that structure :-)

MikePelton avatar Jan 16 '23 12:01 MikePelton

Can u please share your solution?

laheller avatar Jan 16 '23 12:01 laheller

It's brute force I'm afraid - we read the image twice - once to get its orientation and then again to apply a correcting transform. We consume hundreds of images from any one camera which is fixed in a rig, so we only need one read to tell us the orientation and can then apply the same transform to the whole feed. Nothing clever I'm afraid!

MikePelton avatar Jan 16 '23 12:01 MikePelton

No problem. Anyway I cannot tell you right now, when I will implement that struc. So far let's keep this issue open.

laheller avatar Jan 16 '23 12:01 laheller