ios - UIImage automatically rotated when loaded from Filemanager -


when take picture in portrait mode, savedimage automatically rotated when setting uiimageview.

nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *filepath = [[paths objectatindex:0] stringbyappendingpathcomponent:@"profilepicture.png"]; [uiimagepngrepresentation(image) writetofile:filepath atomically:yes];  uiimage *savedimage = [uiimage imagewithdata:[nsdata datawithcontentsoffile:filepath]]; 

but when use uiimagejpegrepresentation: writetofile: atomically: method, result image has no issues.

can please explain why didn't image in correct orientation while using uiimagejpegrepresentation & not in uiimagepngrepresentation.

nb: tried

uiimage *imagetodisplay =      [uiimage imagewithcgimage:[originalimage cgimage]               scale:[originalimage scale]               orientation: uiimageorientationup]; 

to save imagetodisplay, not working

its because of rotation flag in exif data of jpeg. every image file has metadata property. if metadata specifies orientation of image ignored other os mac. of images taken having meta data property set right angle. mac shows 90 degree rotated manner. can see same image in proper way in windows os. please check this answer shows more details


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -