Can't edit images created in Photo Library.

I'm very confused by this. I am trying to take a directory of image files from an iPhone (live photos, videos, regular still images, portrait mode images, etc.) and import them into an album in the Photo Library on an iOS device.

The code I've written seems to do exactly what I want it to – it creates images in an album that I've created. That's all good.

However, although the Photos app shows the images as being "Portrait Mode", for example, the are not editable as Portrait Mode images... ie. I cannot change the depth effects of the images.

If I take one of the HEIC files I imported, that was taken in Portrait Mode, and just drop it onto Photos on an iPad it will import with the ability to be edited, as I would expect.

If I import the image programmatically, the way I'm doing it, it recognizes that it is a Portrait Mode image but I cannot edit the depth of field effect in Photos.

Here is the code I'm using to import:

func createStillAssetOnAlbum(asset: URL, album: PHAssetCollection) {
    let photoURL = asset

    PHPhotoLibrary.shared().performChanges ({

        let creationRequest = PHAssetCreationRequest.forAsset()
        let placeHolderAsset = creationRequest.placeholderForCreatedAsset

        creationRequest.addResource(with: .photo, fileURL: photoURL, options: nil)
        
        
        guard let albumChangeRequest = PHAssetCollectionChangeRequest(for: album) else {
            print("album change request has failed")
            return
        }
        albumChangeRequest.addAssets([placeHolderAsset] as NSArray)

        
    }, completionHandler: { success, error in
        if success {
            print("photo (and adjustments) saved successfully")
            self.importCount += 1
        }
        else if let e = error {
            print("error saving photo (and adjustment): \(e)")
            self.nonImportedImageCount += 1
        }
    })
}

Any thoughts as to why an image file that I drop onto an iPad Photos app, that is editable as a portrait mode photo cannot be edited as a portrait mode photo when imported via the method I'm using?

Thank you!

Can't edit images created in Photo Library.
 
 
Q