image
image copied to clipboard
Add a function to apply Exif rotation
This is required to display JPEG photos correctly.
Doesn't wire it up to the JPEG decoding process yet, because that would be a semver-breaking change. But at least provides all the pieces for an API user to apply the correct rotation, together with #2291
Depends on #2292
Why this API?
A common case for a JPEG image is not to be rotated at all, i.e. have the orientation value of 1. Therefore we do not want to unconditionally make a copy of the image - often it is just a no-op. We need to do this in place.
Sadly nobody has implemented in-place 90 and 270 degree rotation yet (see #2294), so we are forced to make a copy in some cases. This copying behavior prevents us from implementing this in imageops module, which is generic over the input and so we cannot use the "replace the input with a copy" trick there.
So there are two options:
- Enshrine the unnecessary copying in the API by returning something like
Result<Option<GenericImage>>
and make the caller deal with it - Only implement Exif rotation on DynamicImage until #2294 is fixed
This PR picks the second option.