如何在不更改图像的情况下更新ALAsset的exif?

2024-01-10

I use setImageData:metadata:completionBlock: of ALAsset更新资产的 exif(元数据)。

我只想更新元数据,但此方法需要imageData作为第一个参数。我使用下面的代码来生成imageData,但它修改了我的图像(我检查了文件大小和文件哈希)。

ALAssetRepresentation *dr = asset.defaultRepresentation;
UIImage *image = [UIImage imageWithCGImage:dr.fullResolutionImage scale:dr.scale orientation:dr.orientation];
NSData *data = UIImageJPEGRepresentation(image, 1);

有没有其他方法可以用来更新 exifALAsset?或者任何方式来生成正确的imageData对于方法setImageData:metadata:completionBlock: ?


我找到了一种生成方法imageData。代码如下:

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:仅更新 exifALAsset.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在不更改图像的情况下更新ALAsset的exif? 的相关文章

随机推荐