On Mac, rotating image in Finder does not result in rotated image after loading
Opened this issue · 8 comments
Here's the code:
SDL_Surface* surface = IMG_Load(path.string().c_str());
This works usually, but if I use the Mac Finder to rotate an image (command-L), the image appears rotated in the Finder, but loads with the original orientation in SDLImage.
I suspect this is some kind of optimization in MacOS to make rotation a change in metadata instead of actually rotating the image pixels to save time, but I'm not sure.
Can you attach a link to a rotated image?
Just in case uploading alters the image somehow, here it is compressed.
What happens if you remove the __MACOSX
folder next to the image?
gimp and gnome's image viewer also show the image as non-rotated.
I opened the file in imhex, and see an embedded iTXT
chunk with a ML:com.adobe.xmp
key, containing:
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 6.0.0">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:xmp="http://ns.adobe.com/xap/1.0/"
xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"
xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#"
xmlns:tiff="http://ns.adobe.com/tiff/1.0/"
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
dc:format="image/png"
xmp:CreatorTool="Adobe Photoshop 24.4 (Macintosh)"
xmp:ModifyDate="2023-05-09T19:32:18-07:00"
xmp:CreateDate="2022-11-16T19:14:27-08:00"
xmp:MetadataDate="2023-05-09T19:32:18-07:00"
xmpMM:OriginalDocumentID="xmp.did:9d46c96f-0c34-4c07-a596-61726ed10945"
xmpMM:DocumentID="xmp.did:9d46c96f-0c34-4c07-a596-61726ed10945"
xmpMM:InstanceID="xmp.iid:9d46c96f-0c34-4c07-a596-61726ed10945"
tiff:Orientation="8"
photoshop:ColorMode="3">
<xmpMM:History>
<rdf:Seq>
<rdf:li
stEvt:softwareAgent="Adobe Photoshop 24.4 (Macintosh)"
stEvt:when="2022-11-16T19:14:27-08:00"
stEvt:instanceID="xmp.iid:9d46c96f-0c34-4c07-a596-61726ed10945"
stEvt:action="created"/>
</rdf:Seq>
</xmpMM:History>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end="r"?>
SDL_image does not have a xml parser.
I would say, if it's difficult to fix, maybe just document it somewhere. Because it is confusing for Mac users.
Not the end of the world, since we can rotate with other apps than the Finder, just less convenient.