Resizing images in Rust, now with EXIF orientation support

(alexwlchan.net)

31 points | by ingve 4 days ago ago

7 comments

  • esperent an hour ago

    I'm sure there's very good reasoning but I've never been able to convince myself of it - why does exif transform metadata exist? If you're taking a selfie, why doesn't the camera itself perform a simple rotation or mirror of the actual imagine data rather than using exif?

    • Doohickey-d 42 minutes ago

      One reason I can think of: when you rotate an image in the windows photo viewer (and probably lots of other apps), it stores that in the EXIF metadata. So the rotation is lossless, by not having to re-compress the JPEG.

      I could also imagine that the earliest digital cameras wouldn't have had the processing power, or RAM to store the entire image in memory after reading it from the sensor, in order to do such a rotation. Hence EXIF rotation as a cheap alternative.

    • blululu 9 minutes ago

      I too have always found this strange but I have never found a solid reason. Having an explicit declaration of intent is not a terrible feature in a data type so this is not exactly a bad choice. Also this means that a camera roll from a single sensor can be stored as an array in C since every image has the exact same size. It also does make life easier for the camera developers (but harder for photo viewer developers). If anyone knows the history here I would actually really be interested.

    • tinco an hour ago

      I think it does this after the photo has already been stored as JPEG. I think users would expect the image be persisted the moment you capture it, so any transformations after that are better done in metadata. When the image has been saved as JPEG the original image data is discarded so you can't transform without deteriorating the image.

      • dividuum 42 minutes ago

        Pretty sure you can rotate JPEG images lossless. But it’s still simpler to just modify metadata.

        • perching_aix a minute ago

          A quick search suggests to me that it's only lossless if the image dimensions are a clean integer multiple of 8, otherwise the edges must be reencoded.