请推荐用于将IPTC数据写入图像的节点模块



我有一个Node.js服务器,它的工作是下载JPEG图像,将某些数据写入几个IPTC字段(例如Iptc.Application2.Caption(,并将图像传递给另一个服务。

理想情况下,我希望将IPTC数据写入内存缓冲区(而不将图像写入本地文件系统(。如果做不到这一点,我可以使用一个解决方案,下载文件,将文件存储到FS,然后应用IPTC数据。

我有这个工作https://github.com/dberesford/exiv2node,但它在Node.js v10上不起作用。它依赖于exiv2 C++库,这使得容器化运行变得很混乱。

所以我的问题是:有没有一个像样的Node.js模块可以实现IPTC数据写入,并且不依赖于一些怪物C库?

我会使用exiftool vendored,它只是exiftool命令行实用程序的包装器。它还将安装exiftool二进制文件,如果你已经安装了exiftool,你可以在没有这个二进制的情况下使用exiftool

安装exiftool:

npm install --save exiftool-vendored

您添加的标签被放在支持它们的规范中,在本例中是IPTC。

例如,我将添加ArtistCopyright标签,exiftool将放置相应的IPTC标签。

const exiftool = require("exiftool-vendored").exiftool
const tags = {
artist:"David Lemon", 
copyright:"2018 David Lemon"  
};
exiftool.write("outernet.jpeg", tags);

exiftool.write将返回一个您可以在计算其他事物时等待的承诺。关于承诺的更多信息。

使用exiftool CLI,您可以检查标记是否正确写入文件:

$ node_modules/exiftool-vendored.exe/bin/exiftool.exe outernet.jpeg
ExifTool Version Number         : 11.20
File Name                       : outernet.jpeg
Directory                       : .
File Size                       : 4.6 kB
[...]
Artist                          : David Lemon
Y Cb Cr Positioning             : Centered
Copyright                       : 2018 David Lemon
Current IPTC Digest             : 2b3df19b0c67788262a0d0dced3b6d58
Coded Character Set             : UTF8
Envelope Record Version         : 4
[...]

最新更新