Starting with iOS 26.6, saving an image to the photo library via
PHAssetCreationRequest.addResource(with: .photo, data:, options:) appears to
re-encode the image, dropping all EXIF metadata. The same code preserved
metadata through iOS 26.5.
let creationRequest = PHAssetCreationRequest.forAsset()
creationRequest.addResource(with: .photo, data: image, options: nil)
I would like to know whether this change is intentional, and whether the file-based overload is the supported way to preserve an image's original metadata.
What we verified
-
The bytes we hand to PhotoKit still contain the metadata.
-
Setting
contentTypeexplicitly does not help. We resolved the type from the data and confirmed at runtime that it was non-nil (public.jpeg):
let options = PHAssetResourceCreationOptions()
if #available(iOS 26.0, *) {
options.contentType = contentType // verified: UTType.jpeg, not nil
}
let request = PHAssetCreationRequest.forAsset()
request.addResource(with: .photo, data: imageData, options: options)
- The resulting asset still has no EXIF.
- Writing the identical bytes to a temporary file and using the file-based overload preserves everything:
try imageData.write(to: temporaryFileURL, options: .atomic)
let options = PHAssetResourceCreationOptions()
options.shouldMoveFile = true
let request = PHAssetCreationRequest.forAsset()
request.addResource(with: .photo, fileURL: temporaryFileURL, options: options)
- Capture date, camera information and location are all intact.
We access the library with PHAccessLevel.addOnly.