Làm thế nào để bạn loại bỏ tất cả dữ liệu exif trong một UIImage bằng cách sử dụng mục tiêu-c? Tôi đã có thể để có được những dữ liệu Exif sử dụng như sau:Tước tất cả dữ liệu Exif trong mục tiêu-C
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;
Cám ơn câu trả lời của bạn, nó giúp đầy đủ. Nhưng sau khi tôi xóa EXIF && GPS bằng CGImage, dữ liệu hình ảnh được nén khi tôi lưu UIImage bằng "writeImageToSavedPhotosAlbum". Nếu tôi thêm "kCGImageDestinationLossyCompressionQuality" là 1.0 vào "removeExifProperties", hình ảnh đầu ra sẽ lớn hơn dữ liệu gốc. Bạn có bất cứ đề xuất nào để giữ dữ liệu hình ảnh ban đầu nhưng loại bỏ một số siêu dữ liệu như EXIF & GPS không? –