所有:
我在代码后面修改了JPG FILE的exif信息,但是xcode
总是说:
2016-12-28 23:28:39.913239 Image [13598:2429980] [Image] ImageIO:CGImageDestinationCopyImageSource:0:需要kCGImageDestinationMetadata,kCGImageDestinationOrientation或kCGImageDestinationDateTime之一。
我不知道为什么?以及如何正确修改。
void test1(){
NSString *path = @"/Users/feinno/Desktop/Aerial01.jpg";
NSData *imageData = [NSData dataWithContentsOfFile:path];
CGImageSourceRef isrc = CGImageSourceCreateWithData((__bridge_retained CFDataRef)imageData, NULL);
CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(isrc, 0, NULL);
CFMutableDictionaryRef mutableProperties = CFDictionaryCreateMutableCopy(NULL, 0, properties);
NSLog(@"%@", mutableProperties);
CFDictionaryRef tiffProperties = CFDictionaryGetValue(mutableProperties, kCGImagePropertyTIFFDictionary);
CFMutableDictionaryRef tiffProfsMut = CFDictionaryCreateMutableCopy(NULL, 0, tiffProperties);
NSString *value = @"md5: 123";
CFDictionarySetValue(tiffProfsMut, kCGImagePropertyTIFFModel, (__bridge const void *)value);
CFDictionarySetValue(mutableProperties, kCGImagePropertyTIFFDictionary, tiffProfsMut);
CFRelease(tiffProfsMut);
NSLog(@"%@", mutableProperties);
CFStringRef UTI = CGImageSourceGetType(isrc);
NSMutableData *newImageData = [NSMutableData data];
CGImageDestinationRef idst = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)newImageData, UTI, 1, NULL);
CFMutableDictionaryRef options = CFDictionaryCreateMutable(CFAllocatorGetDefault(), 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(options, kCGImageDestinationMergeMetadata, kCFBooleanTrue);
CFErrorRef error;
CGImageDestinationCopyImageSource(idst, isrc, options, &error);
}