Skip to content

IMRead() with IMReadUnchanged flag ignores EXIF orientation, when it should preserve it #15786

Description

@Alexn117
System information (version)
  • OpenCV => 4.1.2
  • Operating System / Platform => macOS Catalina version: 10.15
  • Compiler => gocv version: 0.21.0
Detailed description

The documentation seems to indicate that an image's EXIF orientation will be preserved, unless the IMREAD_IGNORE_ORIENTATION flag is set. But when I set the IMREAD_UNCHANGED flag, the EXIF orientation is also not preserved. Strangely, if I use IMREAD_COLOR, it is preserved.

If EXIF information are embedded in the image file, the EXIF orientation will be taken into account and thus the image will be rotated accordingly except if the flag IMREAD_IGNORE_ORIENTATION is passed.
https://docs.opencv.org/master/d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56

IMREAD_IGNORE_ORIENTATION | If set, do not rotate the image according to EXIF's orientation flag.
https://docs.opencv.org/master/d4/da8/group__imgcodecs.html#ga61d9b0126a3e57d9277ac48327799c80

Steps to reproduce

EXIF orientation is ignored, even though the IMREAD_IGNORE_ORIENTATION flag is not being set:

img := gocv.IMRead(name, gocv.IMReadUnchanged)

EXIF orientation is preserved:

img := gocv.IMRead(name, gocv.IMReadColor)

EDIT: sample image
IMG_3543 - no location

Activity

  1. alalek commented on Oct 26, 2019

    @alalek
    Member

    Please attach sample image.

    BTW, Not all image codecs in OpencV support EXIF.

  2. Alexn117 commented on Oct 26, 2019

    @Alexn117
    Author

    Please attach sample image.

    BTW, Not all image codecs in OpencV support EXIF.

    I attached the image to the post.

  3. alalek commented on Oct 26, 2019

    @alalek
    Member

    IMREAD_COLOR(1) - apples EXIF
    IMREAD_IGNORE_ORIENTATION = IMREAD_IGNORE_ORIENTATION | IMREAD_GRAYSCALE(128) - doesn't apply EXIF
    IMREAD_UNCHANGED(-1) - doesn't apply EXIF too

    Image is handled as expected.

    IMREAD_UNCHANGED documentation says:

    If set, return the loaded image as is (with alpha channel, otherwise it gets cropped).

    If you want to improve documentation, feel free to propose a PR

  4. added
    Hackathon
    on Jan 31, 2020
  5. collinbrake commented on Feb 6, 2020

    @collinbrake
    Contributor

    @alalek I proposed a PR to improve the documentation for the IMREAD_UNCHANGED flag. Should the documentation for the imread() function also be changed?

    If EXIF information are embedded in the image file, the EXIF orientation will be taken into account and thus the image will be rotated accordingly except if the flag IMREAD_IGNORE_ORIENTATION is passed.

  6. preeti13456 commented on Feb 7, 2020

    @preeti13456

    I proposed a PR to image_ignore_orientation can we change the params(parameters) . And can we use image_frame(length,width) and change the orientation accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Hackathoncategory: documentationcategory: imgcodecs

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions