-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(heic): Don't auto-transform camera-rotated images (#4142)
It seems that unlike most image formats where we merely note the camera rotation but don't rotate the pixels, the heic reader automatically rotated. The trick is that using the C++ API wrapper of libheif, there is no way to pass the decoder options struct that is where you need to say not to auto-transform. Needed to drop down to the lower level C API for this one spot. We want this format to behave like the others -- the orientation is advisory, and it's up to the app how to deal with it. But we have back compatibility to deal with. If a rotated image is aecountered, OIIO 2.5 and earlier will by default still auto-rotate to preserve compatibility, but OIIO 2.6+ will not auto-rotate. When not rotating, the Orientation metadata will reflect the desired display orientation of the image, according to what was in the file. When auto-rotating, Orientation will be 1 (canonical display orientation), and a new attribute "heif:Orientation" will reflect what was originally in the file. When opening a file for input, the special configuration metadata hint "heif:reorient" can express a preference for auto-rotation, overriding the default. Thus, setting this hint to 0 for OIIO 2.5 will turn off auto-rotation, and setting it to 1 for OIIO 2.6+ will make it auto-rotate like it used to do. I also added some additional tests for heif files. Along the way I fixed a rather embarrassing documentation problem as well, where all the orientation codes were "off by 1", oh boy. Fixes #4123 --------- Signed-off-by: Larry Gritz <[email protected]>
- Loading branch information
Showing
10 changed files
with
593 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.