Kingfisher: Wrong image orientation - Images get rotated after saved to disk

Created on 5 Aug 2015  ·  1Comment  ·  Source: onevcat/Kingfisher

UIImage instances that are created from JPEGs have imageOrientation set accordingly.

When an image is later saved to the disk in JPEG format, the orientation is persisted too in EXIF information. Therefore, when it's loaded later on from disk, it has the correct orientation.

However, Kingfisher is using PNG serialization rather than JPEG that doesn't support the rotation flag (metadata about orientation is not persisted). source: http://stackoverflow.com/a/4868914/1161723

Most helpful comment

There are two possible solutions:

1) Use UIImageJPEGRepresentation instead of UIImagePNGRepresentation when saving an image to disk

2) Rotate the instance of UIImage using its imageOrientation property before saving it to disk as a PNG image, possible implementation could look like this (objc code): http://stackoverflow.com/a/5427890/1161723

>All comments

There are two possible solutions:

1) Use UIImageJPEGRepresentation instead of UIImagePNGRepresentation when saving an image to disk

2) Rotate the instance of UIImage using its imageOrientation property before saving it to disk as a PNG image, possible implementation could look like this (objc code): http://stackoverflow.com/a/5427890/1161723

Was this page helpful?
0 / 5 - 0 ratings