如何使用objective-c剝離UIImage中的所有exif數據?我已經能夠用得到的EXIF數據如下:剝離Objective-C中的所有Exif數據
NSData* pngData = UIImagePNGRepresentation(image);
CGImageSourceRef imageSource = CGImageSourceCreateWithData((CFDataRef)pngData, NULL);
NSDictionary* dic = nil;
if (NULL == imageSource)
{
#ifdef _DEBUG
CGImageSourceStatus status = CGImageSourceGetStatus (source);
NSLog (@"Error: file name : %@ - Status: %d", file, status);
#endif
}
else
{
CFDictionaryRef propertyRef = CGImageSourceCopyPropertiesAtIndex (imageSource, 0, NULL);
CGImageMetadataRef metadataRef = CGImageSourceCopyMetadataAtIndex (imageSource, 0, NULL);
// CFDictionaryRef metadataRef = CFDictionaryGetValue(imageProperties, kCGImagePropertyExifDictionary);
if (metadataRef) {
NSDictionary* immutableMetadata = (NSDictionary *)metadataRef;
if (immutableMetadata) {
dic = [ NSDictionary dictionaryWithDictionary : (NSDictionary *)metadataRef ];
}
CFRelease (metadataRef);
}
CFRelease(imageSource);
imageSource = nil;
}
return dic;
謝謝您的回答,這是幫助全。 但我用CGImage刪除EXIF && GPS後,圖像數據被壓縮,因爲我通過「writeImageToSavedPhotosAlbum」保存UIImage。 如果我將「kCGImageDestinationLossyCompressionQuality」添加爲1.0到「removeExifProperties」,則輸出圖像會比原始數據大。 你有任何建議保持圖像數據爲原始的,但剝離EXIF和GPS一些元數據? – 2015-04-16 08:56:25