简体   繁体   English

node - 从图像缓冲区解析 iptc 数据

[英]node - Parse iptc data from image buffer

Trying to find a way to extract IPTC data from an image file buffer, there are existing libraries available on npm that allow you to open and read a file from the local filesystem but i am storing files on AWS S3 and would prefer to use buffers instead of creating unnecessary disk writes.试图找到一种从图像文件缓冲区中提取 IPTC 数据的方法,npm 上有可用的现有库,允许您从本地文件系统打开和读取文件,但我将文件存储在 AWS S3 上,并且更喜欢使用缓冲区创建不必要的磁盘写入。

Not sure where to start, maybe start looking through how this module works: https://www.npmjs.com/package/extract-iptc And create my own module?不知道从哪里开始,也许开始研究这个模块是如何工作的: https : //www.npmjs.com/package/extract-iptc并创建我自己的模块? Or is there an easier way that i've missed?或者有没有我错过的更简单的方法?

I was able to extract IPTC data by using我能够通过使用提取 IPTC 数据

var iptc = require('node-iptc');
var iptc_data = iptc(imageData);

Also there's an isomorphic library exifr that works in both Node.js and browser.还有一个同构库exifr可以在 Node.js 和浏览器中使用。 And it works with the new HEIC image format as well.它也适用于新的 HEIC 图像格式。

exifr.parse(input, {iptc: true}).then(output => {
  console.log('IPTC', output)
})

It parses multiple formats (TIFF/EXIF, ICC, IPTC, XMP, JFIF) but IPTC isn't enabled by default so you need to enabled it in options as seen in the example.它解析多种格式(TIFF/EXIF、ICC、IPTC、XMP、JFIF),但默认情况下未启用 IPTC,因此您需要在示例中看到的选项中启用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM