Most active commenters

    ←back to thread

    94 points justin-reeves | 17 comments | | HN request time: 1.467s | source | bottom
    1. mzur ◴[] No.46005353[source]
    Browsers starting to rotate images based on EXIF is such a pain. I maintain an image annotation tool and all of a sudden images were shown differently to users depending on the browser they used. Then you have to jump through all sorts of hoops to ignore the EXIF orientation again. In some cases you are not allowed to see if the orientation was changed for security reasons. And then the only way to control this is through a CSS attribute which only works if the element is in the DOM.
    replies(5): >>46005381 #>>46005382 #>>46005519 #>>46005618 #>>46006856 #
    2. Linkd ◴[] No.46005381[source]
    The amount of time I've spent dealing with this over the years is just incredible.. It's gotten to the point where during ingestion we auto-rotate everything just in case and strip out exif orientation metadata and never have to deal with it again.
    replies(2): >>46008912 #>>46009973 #
    3. bastawhiz ◴[] No.46005382[source]
    > In some cases you are not allowed to see if the orientation was changed for security reasons.

    This is only true for cross-origin images, no? Which is expected: you can't access data loaded from another origin unless it's been loaded with CORS.

    4. coldpie ◴[] No.46005519[source]
    Yes. I wrote a little image uploader script to easily upload images from my phone for embedding in web forums etc, and it strips out all the EXIF orientation and just converts it to the correct orientation. Aside from that I'm always having to fiddle with it in my image tools and hope every software I use supports it. It's such a crap feature. Just rotate the damn image, phones!
    replies(1): >>46005560 #
    5. circuit10 ◴[] No.46005560[source]
    Wouldn’t that degrade the quality for a lossy format, especially if done repeatedly? I see why people would not want their phone to do that. If you’re uploading it somewhere that might not be supported it would be worth it but I don’t want my phone to silently degrade images that are just sitting in my gallery
    replies(2): >>46005621 #>>46005855 #
    6. stackedinserter ◴[] No.46005618[source]
    I maintain a photo library project, I feel your pain. JPEG format is so crooked in so many ways.

    It's shame that after so many years of development we ended up with such horrible formats like jpeg and mp4.

    7. justincormack ◴[] No.46005621{3}[source]
    JPEG allows for lossless 90 degree rotation, not sure about other formats
    replies(2): >>46005817 #>>46008716 #
    8. derefr ◴[] No.46005817{4}[source]
    Pretty sure that any software from after ~2005 that supports image rotation, isn’t doing so at decoding time, but rather is decoding the image into a GPU texture buffer and then rotating the quad that texture gets applied to. Which should always be lossless for multiple-of-90-degree rotations. (Presuming that the image doesn’t depend on sub-pixel rendering tricks.)
    replies(1): >>46005969 #
    9. coldpie ◴[] No.46005855{3}[source]
    Rotate it at capture time, before encoding. This would get rid of like 95% of these exif orientation tags. For images that need to be manually rotated after for whatever reason, sure I guess you have a point, though I'd argue the quality loss would be unnoticeable in practice unless you're like spinning the image in circles 100 times for some reason.
    10. ryandrake ◴[] No.46005969{5}[source]
    Even without a GPU, the JPEG format itself allows for totally lossless rotation. It is also quite fast, and doesn't require reading and writing every pixel in the image.
    replies(1): >>46008286 #
    11. taeric ◴[] No.46006856[source]
    Isn't it a touch on the required side, though? I'm assuming the orientation is a common metadata element of phone produced images, in particular. I'd assume same for decent cameras.

    Would love to see a good rundown of when you should rely on different approaches? Another thread pointed out that you should also use the color space metadata.

    replies(1): >>46009116 #
    12. thunderfork ◴[] No.46008286{6}[source]
    Isn't this only true for images where the resolution is divisible by the block size or something like that?

    IIRC in other cases you have to cut the edge of the image off (rounded to the nearest block) or recompress those edge blocks

    13. drewnoakes ◴[] No.46008716{4}[source]
    Is that still true if the image dimensions aren't a multiple of the block size?
    14. jjcm ◴[] No.46008912[source]
    This is the correct approach in my opinion. Metadata should not be used to control rotation - there are just too many edge cases for where it can go wrong.
    15. LeifCarrotson ◴[] No.46009116[source]
    Some systems seem to produce images where the pixel arrangement matches the sensor layout, which moves when you rotate the device, and they'll add EXIF metadata to indicate the orientation.

    Other cameras and phones and apps produce images where the device adjusts the aspect ratio and order of the array of pixels in the image regardless of the way the sensor was pointed, such that the EXIF orientation is always the default 0-degree rotation. I'd argue that this is simpler, it's the way that people ignorant of the existence of the metadata method would expect the system to work. That method always works on any device or browser, rotating with EXIF only works if your whole pipeline is aware of that method.

    replies(1): >>46009215 #
    16. taeric ◴[] No.46009215{3}[source]
    The advantage of the EXIF approach is you don't have to do nearly as much post processing of the data? In particular, I don't expect my camera application to need to change memory layout just because I have rotated my camera. So, if you want it to change the rows/columns on saving the image, that has to be post capture from the sensor. Right?

    I think this is what you meant by "some systems" there. But, I would expect that of every sensor system? I legit never would have considered that they would try the transpose on saving the image off the sensor.

    17. drittich ◴[] No.46009973[source]
    Yes, came to the same conclusion - it's a pain, but solves the problem permanently.