UIImagePNGRepresentation issues? / Images rotated by 90 degrees

前端 未结 6 784
臣服心动
臣服心动 2020-11-29 20:30

I want to load images from UIImagePickerController, then save the selected photo to my app\'s document directory.

UIImage *image = [info objectForKey:UIImage         


        
6条回答
  •  悲哀的现实
    2020-11-29 21:03

    I had the same problem and just figured out the reason: starting with iOS 4.0 when the camera takes a photo it does not rotate it before saving, it simply sets a rotation flag in the EXIF data of the JPEG.

    If you save a UIImage as a JPEG, it will set the rotation flag.

    PNGs do not support a rotation flag, so if you save a UIImage as a PNG, it will be rotated incorrectly and not have a flag set to fix it. So if you want PNGs you must rotate them yourself.

    I would call this a bug in the PNG saving function but that's just an opinion (they should at least warn you about this).

提交回复
热议问题