EAA*_*EAA 7 fonts imagemagick node-imagemagick imagemagick-convert
我正在将 ImageMagick 命令集成到用 Node.js 编写的 Firebase 函数中。我已经安装了 Ghostscript 并拥有可用字体的完整列表:
convert -list font
Path: /usr/local/Cellar/imagemagick/7.0.8-10/etc/ImageMagick-7/type-apple.xml
Font: AndaleMono
family: Andale Mono
style: Undefined
stretch: Undefined
weight: 0
glyphs: /Library/Fonts//Andale Mono.ttf
Font: AppleChancery
family: Apple Chancery
style: Undefined
stretch: Undefined
weight: 0
glyphs: /Library/Fonts//Apple Chancery.ttf
Font: AppleMyungjo
family: AppleMyungjo
style: Undefined
stretch: Undefined
weight: 0
glyphs: /Library/Fonts//AppleMyungjo.ttf
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
exec(`convert ${tempFilePath} -font /Users/emma/Library/Fonts/Nunito-Regular.ttf -fill white -pointsize 60 -gravity center -draw "text 0,300 'this is a label'" ${tempFilePath}`, {stdio: 'ignore'}, (err, stdout) => {
if (err) {
console.error('Failed to label image.', err);
reject(err);
} else {
resolve(stdout);
}
});
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
exec(`convert ${tempFilePath} -font Arial -fill white -pointsize 60 -gravity center -draw "text 0,300 'this is a label'" ${tempFilePath}`, {stdio: 'ignore'}, (err, stdout) => {
if (err) {
console.error('Failed to label image.', err);
reject(err);
} else {
resolve(stdout);
}
});
Run Code Online (Sandbox Code Playgroud)
我收到的错误是:
convert: unable to read font `/Library/Fonts//Andale' @ warning/annotate.c/RenderType/872
Run Code Online (Sandbox Code Playgroud)
根据@fmw42建议:
在某些使用 Imagemagick 的工具上,它们不使用系统 ENV 变量。
所以我见过 PHP Imagick 等无法找到 Ghostscript 的情况。
在这些情况下,解决方案是将 Ghostscript 的完整路径放在Imagemagick 文件
gs
中用于列出 的 PS、EPS 等行的位置。delegates.xml
gs
请参阅https://imagemagick.org/script/resources.php及其
delegates.xml
可能的位置。我的位于/usr/local/etc/ImageMagick-6/delegates.xml
所以可能的解决办法是安装gs
工具。
在 MacOS 上:brew install gs
.
相关文章:https://imagemagick.org/discourse-server/viewtopic.php ?t= 34911。
归档时间: |
|
查看次数: |
3999 次 |
最近记录: |