Skip to content

IMREAD_ANYCOLOR return BGR on BGRA png image #21695

@maingoh

Description

@maingoh
System information (version)
  • OpenCV => 4.5.5
  • Operating System / Platform => Ubuntu 20.04
  • Compiler => g++
Detailed description

I have the following constraints when I open images:

I cannot use IMREAD_UNCHANGED because it will ignore the exif orientation. So I thought IMREAD_ANYCOLOR was exactly what I wanted, but it seem to have the same behavior than IMREAD_COLOR as it returns a BGRA image directly in BGR format.
The documentation is not so clear, but I expected it to respect the number of channel of the initial file, converting it to 8U (if not associated with IMREAD_ANYDEPTH) and applying the exif orientation.

If I wrongly interpreted IMREAD_ANYCOLOR, maybe another IMREAD flag is missing for my use case, or a way to apply the exif orientation afterward can be useful (just like PIL does).

Steps to reproduce
import cv2

img = cv2.imread(path, cv2.IMREAD_ANYCOLOR)
print(img.shape)

test

Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions