English 中文(简体)
如何通过 Firebase 将 EXIF 数据从上传到 Cloud 存储处的文件中删除
原标题:How to remove EXIF data from file uploaded to Cloud Storage via Firebase

我正通过Firebase Stready SDK将文件,包括带定位数据的手机上的照片和视频上传到一个云存桶。 我怎样才能从这些文件中移除 EXIF 数据? 最好在客户端删除它们, 但如果需要 Cloud 函数的话, 可以罚款 。

问题回答

您可以使用 < 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 删除

快乐编码 :)





相关问题
How to get the EXIF or meta-data from images?

I need a really good library or a command-line software that can be used to extract Exif data from images. No specific programming language, except the library or the software has to work really well. ...

libexif example to add a small Xml document in the exif data

Any libexif user/developer that could point me in the right direction on what are the appropriate call for adding a small custom XML document in the exif meta data of a JPG image ? I have been ...

Calculating EXIF exposure time as a fraction (Delphi)

I am trying to display EXIF exposure time as a fraction of seconds but I am not getting expected result, probably a small mistake. I have found two routines that do the calculation but both bring ...

Checksum JPEG data (not the whole file)

Are there end-of-exif / end-of-xmp / end-of-iptc / start-of-data markers that I could use to get a checksum of just the data part of a jpg / jpeg (and other image formats)?

How is exif info encoded?

Greetings, I m going to get exif info from some images using android. I know there are some standard java lib s out there that I could use with the device. I m sure I will end up using one. But in ...

Access EXIF data in a NEF (Nikon) file

How can I access the EXIF data stored in a Nikon NEF file? I can t seem to find a lib that will allow me to extract some basic information from the metadata. (Preferably without having to install ...

热门标签