How do you strip all exif data in a UIImage using objective-c? I have been able to get the exif data using the following :
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;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…