Is UIImageOrientation incorrect for the left / right side of a loaded UIImage?

I load JPGs marked with arbitrary EXIF ​​orientation data (one of 8 orientations). I have uploaded eight model image files here (link from this blog post ).

Image 8 is an EXIF ​​tag 8, which is a 90 degree rotation clockwise . This can be confirmed by looking at this image in a silent viewer, such as Paintbrush.

However, when I load it into UIImage in my iOS project and call -imageOrientation on it, I get UIImageOrientationLeft . According to the docs ,

UIImageOrientationLeft

The image rotates 90 degrees counterclockwise , as shown here.

... this is not how the main image looks.

The opposite refers to the EXIF ​​6 orientation, which I expect to see as left, but which looks like right.

Are the documents incorrect here? Am I missing something? Thanks.

+6
source share
3 answers

I had the same problem for a while. The UIImageOrientation documentation seems to describe what happens with a vertical image if you apply the specified orientation. For example, if you take a vertical image and apply a UIImageOrientationLeft, it will rotate 90 ° counterclockwise.

The exif documentation, on the other hand, describes what the orientation of the image data is for creating a vertical image. Therefore, for the EXIF ​​8 code, the image data must be rotated 90 ° clockwise to display a vertical image.

It turns out that this problem has only UIImageOrientationLeft and UIImageOrientationRight, since everything else comes out the same way you look at it.

+8
source

I think the problem is at the starting point (where the rotation is applied). When using UIImage, the origin is in the upper left corner, and when using CGImage, the origin is in the lower left corner.

+1
source

I found an interesting answer to this question: http://blog.logichigh.com/2008/06/05/uiimage-fix/

0
source

Source: https://habr.com/ru/post/895994/


All Articles