2
我想直接保存alasset imagearray到文档目录与EXIF 我试过PNG转换,JPEG转换没有什么工作 它只是创造新形象要么JPG或PNG (EXIF的损失)从ALAsset对象写入与Exif原始图片到文档目录文件夹
我已经看到了一些时间回去救NSData的直接到文件夹保留EXIF不知道如何
我得到的元数据ALAsset对象结果和
NSDictionary *metadata = [[result defaultRepresentation] metadata];
另一个资产阵列的所有图像
ALAssetsGroupEnumerationResultsBlock assetEnumerator = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
if(result != NULL) {
[assets addObject:result];
;
NSLog(@"assets %i",[assets count]);
self.progressView.progress = (float)index/([assets count]-1);
}
影像保存到文档目录的文件夹列表
-(void)saveImagesToDocumentDirectory{
NSLog(@"assets count %i",[assets count]);
for(int i=0;i<[assets count];i++)
{
currentImage = [UIImage imageWithCGImage:[[[assets objectAtIndex:i] defaultRepresentation] fullResolutionImage]];
[self saveImage:currentImage withImageName:[NSString stringWithFormat:@"Images %d",i]];
} }
- (void)saveImage:(UIImage*)image withImageName:(NSString*)imageName {
NSData *imageData = UIImagePNGRepresentation(image); //convert image into .png format.
// NSData *imageData = UIImageJPEGRepresentation(image,1.0);
NSFileManager *fileManager = [NSFileManager defaultManager];//create instance of NSFileManager
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //create an array and store result of our search for the documents directory in it
NSString *documentsDirectory = [paths objectAtIndex:0]; //create NSString object, that holds our exact path to the documents directory
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"MyFolder"];
NSString *fullPath = [dataPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png", imageName]]; //add our image to the path
[fileManager createFileAtPath:fullPath contents:imageData attributes:nil]; //finally save the path (image)
NSLog(@"image saved");
}