Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upOpenCV does not respect exif orientation in PNG file #16579
Comments
Python 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
|
hey i am not getting that affected file |
@Infinity8sailor Hi, the affected file is the second png in my description, the 2nd image and 3rd image are png/jpg with exif information |
Is this issue still open!?(@alalek ) |
I've been working on this issue for a few days now. I'm extremely familiar with both the exif format now and the code that parses it. The problem is, the current code assumes the exif format found inside the JPG images only. However, PNG's format is different from JPG's, not only can it be found in any arbitrary place between IHDR and IEND, moreover, some of the tags that exist in JPG EXIF chunk were discarded, most notably the APP0 and APP1. |
@OsamaNabih Thank you for looking on this!
Looks like you are right. Not sure that we can properly adapt current Perhaps we should extend Format-specific reader should be able to properly find EXIF chunk of data (own code or through underlying I/O library like Some common code (if format is the same) can be used to decode EXIF buffer. We can try to reuse some part of current |
The tiff reading parts (most of the functions in exif.hpp/cpp) may be reused, however, for the functionality pointed to in this issue (using imread), it only cares about the orientation tag. |
My bad about not including the length, while it's true it doesn't give bytes to read like the JPEG, there's a number of tiff headers to read, so we won't be going on indefinitely. |
System information (version)
Detailed description
PNG format starts to support EXIF information since 2017, but somehow using IMREAD_COLOR to read a PNG file does not respect the orientation
Attached Capture.png and Capture.jpg are two images both with same EXIF orientation information, try both and you can see the difference.
Steps to reproduce