[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *assetChangeRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:saveImage];
if (_collection) {
PHAssetCollectionChangeRequest *assetCollectionChangeRequest = [PHAssetCollectionChangeRequest changeRequestForAssetCollection:_collection];
[assetCollectionChangeRequest addAssets:@[[assetChangeRequest placeholderForCreatedAsset]]];
}
} completionHandler:^(BOOL success, NSError *error) {
if (!success)
{
NSLog(@"Error creating asset: %@", error);
}
}];
我使用上面的代码,我在相机胶卷中得到了一张奇怪的照片,比如照片 1。
但是当我用 VSCO 或 snapseed 打开保存的照片时,我可以得到我保存的正确版本的普通版本。
这是苹果相机胶卷的错误吗?
很奇怪,如果我直接将inputData保存到照片库,但是添加元数据后,系统照片应用程序中的照片看起来不清晰。
-(NSData*)getDataOfImage:(UIImage *)image
metaData:(NSDictionary *)metaData
{
NSData *inputData = UIImageJPEGRepresentation(image,1.0);
CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef) inputData,nil);
NSMutableData *outputData = [NSMutableData new];
CFStringRef UTI = CGImageSourceGetType(imageSource);
CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef) outputData, UTI, 1, NULL);
CGImageDestinationAddImageFromSource (imageDestination, imageSource, 0, (__bridge CFMutableDictionaryRef)metaData);
BOOL result = CGImageDestinationFinalize(imageDestination);
if (result == YES) {
NSLog(@"success: save MetaData");
}else{
NSLog(@"failed :save MetaData ");
}
CFRelease(imageSource);
CFRelease(UTI);
CFRelease(imageDestination);
return outputData;
}