修改图像元数据而不压缩它

时间:2017-01-13 10:19:04

标签: objective-c macos metadata core-media

这是我的代码。

CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef) data, NULL);
CFStringRef imageType = CGImageSourceGetType(source);
NSMutableData *resultData = [NSMutableData alloc];
CFDictionaryRef tempp= CGImageSourceCopyPropertiesAtIndex(source, 0, NULL);
CGImageDestinationRef imgDest = CGImageDestinationCreateWithData((__bridge `CFMutableDataRef)(resultData), imageType, 1,  (__bridge CFDictionaryRef)dictionary);`

现在他们是2回写图像的方法。

- >此方法正在压缩图像的大小,但完美地编写元数据

CGImageDestinationAddImageFromSource(imgDest, source, 0, (__bridge CFDictionaryRef)dictionary);
CGImageDestinationFinalize(imgDest);
[resultData writeToFile:[NSURL URLWithString:@"/Users/jamil/Desktop/19nov/DSC_3170a.jpg"].path atomically:YES];

- >另一个不是压缩图像,而是不写元数据。

CGImageDestinationCopyImageSource(imgDest, source, (__bridge CFDictionaryRef)dictionary, NULL);
[resultData writeToFile:[NSURL URLWithString:@"/Users/jamil/Desktop/19nov/DSC_3170a.jpg"].path atomically:YES];

dictionary格式正确,还包括kCGImageDestinationMergeMetadatakCGImageDestinationMetadata

0 个答案:

没有答案