Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions Source/Helpers/Extensions/PHCachingImageManager+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,24 @@ extension PHCachingImageManager {
height: targetSize.height)
if let imageRef = image.cgImage?.cropping(to: scaledCropRect) {
let croppedImage = UIImage(cgImage: imageRef)
let exifs = self.metadataForImageData(data: data)
let exifs = self.exifDataForImageData(data: data)
callback(croppedImage, exifs)
}
}
}
}

private func metadataForImageData(data: Data) -> [String: Any] {
private func exifDataForImageData(data: Data) -> [String: Any] {
var exifData: [String: Any] = [:]

if let imageSource = CGImageSourceCreateWithData(data as CFData, nil),
let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil),
let metaData = imageProperties as? [String: Any] {
return metaData
let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil),
let propertiesDict = imageProperties as? [String: Any],
let exifDict = propertiesDict[kCGImagePropertyExifDictionary as String] as? [String: Any] {
exifData = exifDict
}
return [:]

return exifData
}

func fetchPreviewFor(video asset: PHAsset, callback: @escaping (UIImage) -> Void) {
Expand Down