0

How can I change orientation property (to avoid re-encoding upon rotation) on image stored in iOS Photo Library ? I was trying to search for corresponding method or propery on PHAsset (where I'd expect it), but with no luck.

Michal.Jan008
  • 135
  • 11
  • Do you mean https://developer.apple.com/documentation/photokit/phimagemanager/3237282-requestimagedataandorientation ? – matt Aug 05 '21 at 12:18
  • @matt I mean permanently changing image orientation. The API you shared allows to specify orientation of the image being returned, without modifying stored data. My business usecase is: user observes that there is a picture in the photo library with wrong orientation (e.g. his digi cam had set the orientation incorrectly). Now the user wants to correct this, permanently. – Michal.Jan008 Aug 06 '21 at 12:14
  • Then you don't change a "bit". What you are describing now is a full fledged edit of the photo. That is legal and standard but there isn't some secret back door. This is an x y question. – matt Aug 06 '21 at 12:29
  • I think there is possibility to rotate image (or flip it) - without "full fledged" edit of the photo, as you call it. Each photo has Metadata (EXIF) with integer value in it that describes how to display the image on screen in terms of orientation. Sometimes, this value is wrong, what can be observed as e.g. upside down photo, or horizontal trees, etc. What I'm looking for is a way to change this EXIF tag (actually corresponding property on Photo Library photo), so that the photo could be fixed - without "full fledged" editing of the pixels (causing reencoding the binary). Thanks – Michal.Jan008 Aug 06 '21 at 16:04
  • Okay so this is about editing the metadata? You mean like this? https://stackoverflow.com/questions/41169156/missing-image-metadata-when-saving-updated-image-into-photokit – matt Aug 06 '21 at 16:23
  • ok, I've made some tests and it seems that even Photos App on iOS does not manipulate the orientation flag. Original image may have some non-zero orientation flag, but after rotation the image seems to be reencoded, and the orientation value seems to be reset to zero. After subsequent rotations - there is always zero. So, I tend to believe that I may have been wrong to expect support for this kind of manipulation, yet I still believe that this is natural, when working directly with JPEG files. Thanks for your interest. BR. – Michal.Jan008 Aug 06 '21 at 21:00
  • The point is that these are _NOT_ "jpeg files". They are photo assets. – matt Aug 06 '21 at 22:31

0 Answers0