如何在不更改图像的情况下更新ALAsset的exif? [英] How to update exif of ALAsset without changing the image?
问题描述
我使用ALAsset
的setImageData:metadata:completionBlock:
来更新资产的exif(元数据).
I use setImageData:metadata:completionBlock:
of ALAsset
to update the exif(metadata) of an asset.
我只想更新元数据,但是此方法需要imageData
作为第一个参数.我使用下面的代码生成imageData
,但是它修改了我的图片(我检查了文件大小和文件哈希).
I just want to update the metadata, but this method require an imageData
as the first parameter. I use the code below to generate imageData
, but it modified my image(I checked the file size and file hash).
ALAssetRepresentation *dr = asset.defaultRepresentation;
UIImage *image = [UIImage imageWithCGImage:dr.fullResolutionImage scale:dr.scale orientation:dr.orientation];
NSData *data = UIImageJPEGRepresentation(image, 1);
还有其他方法可以用来更新ALAsset
的exif吗?或为方法setImageData:metadata:completionBlock:
生成正确的imageData
的任何方法?
Is there any other method I could use to update just the exif of an ALAsset
? Or any way to generate the right imageData
for method setImageData:metadata:completionBlock:
?
推荐答案
我找到了一种生成imageData
的方法.下面的代码:
I found a way to generate imageData
. Code below:
Byte *buffer = (Byte *)malloc(dr.size);
NSUInteger k = [dr getBytes:buffer fromOffset:0.0 length:dr.size error:nil];
NSData *data = [NSData dataWithBytesNoCopy:buffer length:k freeWhenDone:YES];
所以我可以将上面的数据与setImageData:metadata:completionBlock:
一起使用,以仅更新ALAsset
的exif.
So I can use the data above with setImageData:metadata:completionBlock:
to update only the exif of ALAsset
.
这篇关于如何在不更改图像的情况下更新ALAsset的exif?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!