A photo of me wearing a blue blazer and pocket square while on a horse, looking quite dapper.

David Celis

A cowboy coder.

Follow me

i would’ve been happy with a light dusting 😳

Did you like this post, repost it, or respond to it? Let me know by sending a webmention!

🌐
5

💬 Replies (21)

okay so after seeing mstdn.link a few weeks ago, i realized it’d be easy to hack twitter-style iMessage link previews for my own site… this post was the first time i tried it with something that had images… and it rotated them all by 180 degrees?? why????

@davidcelis you know that these are coming to iOS 16.4 already, right?

@mckern that’s a link to my website, not mastodon

@davidcelis I'm guessing the exif rotation data isn't being used

@davidcelis 🤷🏻‍♂️ just leave them upside down. for "character".

@xssfox yeah that seems likely. either iMessage is using the EXIF rotation data and my own site isn’t, or vice versa. either way, it’s a lead! thank you!

@davidcelis really giving mount hood a run for its money

i just know that this is gonna be one of those things that honestly does not matter AT ALL and yet i will not be able to let it go

@davidcelis I noticed them loading bottom-to-top on my phone, JPEG rotation bit is such a PITA sometimes

@davidcelis hooo boy, that's a fun one.

Having written an image manipulation service the way things interpret (or do not interpret) exif image rotation (or exif in general) is so arbitrary and dumb. I think I took to doing the rotation and stripping it out of the exif in the end as its mere presence would cause all sorts of silly results.

This was like 12 years ago so I had hoped it was different....but here we are!

@bnferguson what i’ve read is that browsers ignore EXIF orientation, so my guess right now is that rails is using the image_processing gem to automatically rotate images on upload so they appear normal in the browser but then they’re not stripping the orientation out of the EXIF data. what i don’t really understand though is why this iMessage link preview does the rotation when linking to a post but not if i link to an individual image and not if i re-download an image???

@davidcelis I feel like those double rotates are things that I was seeing. Like it got flipped and then displayed but since the exif info was still there something else seemed to read the flipped image, and then applied the exif again for who knows what reasons. Was maddening. But also this was a decade ago so who knows on my memory.

@bnferguson yeah i think i just disproved my theory. i re-downloaded one of those images and it looked normal; once i stripped the EXIF rotation data, it flipped. so maybe you're onto something with the EXIF data being read twice. i have no idea what's going on though because the images end up displaying correctly in the browser, even if i play around with setting an `image-orientation` CSS rule

@bnferguson i think it has to be something the OS is doing though? i noticed this morning that my RSS app also flips the image preview, but in the full article view, which renders HTML, the images appear normally

@davidcelis I feel like yes? This is exactly what I was saying about "arbitrary and dumb" - I had moments where I was sure I was viewing the unrotated image and then it'd be like "JK IT'S ROTATED GOTCHA!"

I started to trust no image viewer. 😂

(You can probably see why I took the, actually rotate the image, write it, strip it approach)

That is wild about the image-orientation bit and the browser just working though. 0_o

@bnferguson yeah that's what really has me confused. since it seems like my images _aren’t_ being automatically rotated, i assumed that i had been reading outdated info about browsers and that there's just a general, global default of `image-orientation: from-image;` so i would have expected `image-orientation: none;` to break things and show them flipped. but it didn't do _anything_! they all still looked normal!

@bnferguson welp, regardless of where the true problem lies, the `ruby-vips` gem thankfully makes it really easy to fix. i can just `autorot` the image when its uploaded and it strips out the exif orientation data at the same time