您可以使用 < a href=> "https://www.npmjs.com/package/exif-js" rel= “ nofollow noreferrer" >exif-js 在上传前删除 EXIF 数据
确保安装 exif-js
软件包,方法是运行 npm i exif-js
或调用 或调用脚本 。
下面的《守则》是执行情况
import exif from exif-js ;
function removeExif(file) {
return new Promise((resolve, reject) => {
exif.getData(file, function() {
// Remove EXIF data
exif.getAllTags(this);
for (const tag in this.exifdata) {
if (tag.startsWith( exif )) {
delete this.exifdata[tag];
}
}
// Create a new Blob with the modified image data
const blob = new Blob([this.getBinary()], { type: file.type });
resolve(blob);
});
});
}
然后在上传功能上,添加 await defeExif( 图像);
因此它应该是类似的东西
const imageWithoutExif = await removeExif(image);
const uploadTask = storageRef.put(imageWithoutExif);
< a href=" "https://i.sstatic.net/9eOqjCKN.png" rel="无跟随 nofollow noreferrer" > 我的图像上传处理器,该处理器在将其放置到 Firebase Cloud 存储 之前调用除去Exif 函数
< a href=" "https://i.sstatic.net/MBVPAgTp.png" rel="无跟踪 noreferrer" >Using exif-js 处理图像上传的 EXIF 删除
快乐编码 :)