all:
I modify exif information of JPG FILE following the codes, but xcode
always says:
2016-12-28 23:28:39.913239 Image[13598:2429980] [Image] ImageIO: CGImageDestinationCopyImageSource:0: One of kCGImageDestinationMetadata, kCGImageDestinationOrientation, or kCGImageDestinationDateTime is required.
I do't know why?and how to modify right.
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);
}