Applying metadata to image causes performChanges request to fail

前端 未结 5 681
感动是毒
感动是毒 2021-02-06 15:29

I am using PhotoKit to edit photos and I need to preserve the metadata from the original photo. To do so I save the metadata then provide it to the options paramete

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-06 15:59

    We are supposed to write the data for the new image to the URL we obtain via

                    let theExportURL = output.renderedContentURL
    

    In my case i was doing this...

                    let outputData = UIImagePNGRepresentation(bakedImage)
    

    And at runtime i was getting the error

    Error Domain=NSCocoaErrorDomain Code=-1 "The operation couldn’t be completed. (Cocoa error -1.)
    

    But when I started exporting the data like this...

    let outputData = UIImageJPEGRepresentation(bakedImage, 1)
    

    It worked. This is documented here ... https://developer.apple.com/library/prerelease/ios/documentation/Photos/Reference/PHContentEditingOutput_Class/index.html

    and this same question has been answered here... https://stackoverflow.com/a/28362235

提交回复
热议问题