Firebase image-magick 转换不工作
Firebase image-magick convert not working
我想在 gif 上写一些文本,然后将其转换为 base 64。但是我遇到了一些我无法解决的错误。我在 Internet 上找到了一些示例,但它们都使用非基于 URI 的本地临时文件。
这是我在我的函数中所做的:
var spawnPromise = spawn(
'convert',
[
`"https://firebasestorage.googleapis.com/v0/b/blizquiz-d9ee2.appspot.com/o/animations%2Fthe-score%2Fbanana.gif?alt=media&token=5c44b0b4-7238-40a3-8ab5-42889781bf60" null:`,
`-fill '#000000' -font "https://firebasestorage.googleapis.com/v0/b/blizquiz-d9ee2.appspot.com/o/animations%2Fthe-score%2FChalkboardSE.ttf?alt=media&token=d83eadaf-9b81-4290-aa12-be6492f0243b" -pointsize 60 -annotate +270+530 '26%'`,
`-layers composite -layers Optimize INLINE:GIF:-`,
],
{capture: ['stdout', 'stderr']},
);
我收到的错误日志:
stderr: convert-im6.q16: unable to open image `"https://firebasestorage.googleapis.com/v0/b/blizquiz-d9ee2.appspot.com/o/animations%2Fthe-score%2Fbanana.gif?alt=media&token=5c44b0b4-7238-40a3-8ab5-42889781bf60" null:': No such file or directory @ error/blob.c/OpenBlob/2701.
convert-im6.q16: no decode delegate for this image format `GIF?ALT=MEDIA&TOKEN=5C44B0B4-7238-40A3-8AB5-42889781BF60" NULL:' @ error/constitute.c/ReadImage/504.
convert-im6.q16: unrecognized option `-fill '#000000' -font "https://firebasestorage.googleapis.com/v0/b/blizquiz-d9ee2.appspot.com/o/animations%2Fthe-score%2FChalkboardSE.ttf?alt=media&token=d83eadaf-9b81-4290-aa12-be6492f0243b" -pointsize 60 -annotate +270+530 '26%'' @ error/convert.c/ConvertImageCommand/1673.
更新
根据收到的反馈,我修改了代码
var spawnPromise = spawn(
'convert',
[
`"https://firebasestorage.googleapis.com/v0/b/blizquiz-d9ee2.appspot.com/o/animations%2Fthe-score%2Fbanana.gif?alt=media&token=5c44b0b4-7238-40a3-8ab5-42889781bf60"`,
`-fill`,
`#000000`,
`-font`,
`"https://firebasestorage.googleapis.com/v0/b/blizquiz-d9ee2.appspot.com/o/animations%2Fthe-score%2FChalkboardSE.ttf?alt=media&token=d83eadaf-9b81-4290-aa12-be6492f0243b"`,
`-pointsize`,
`60`,
`-annotate`,
`+270+530`,
`26%`,
`-layers`,
`composite`,
`-layers`,
`optimize`,
`INLINE:GIF:-`,
],
{capture: ['stdout', 'stderr']},
);
但仍然出现相同的错误,尽管在本地执行时它工作正常。
stderr: convert-im6.q16: unable to open image `"https://firebasestorage.googleapis.com/v0/b/blizquiz-d9ee2.appspot.com/o/animations%2Fthe-score%2Fbanana.gif?alt=media&token=5c44b0b4-7238-40a3-8ab5-42889781bf60"': No such file or directory @ error/blob.c/OpenBlob/2701.
convert-im6.q16: no decode delegate for this image format `GIF?ALT=MEDIA&TOKEN=5C44B0B4-7238-40A3-8AB5-42889781BF60"' @ error/constitute.c/ReadImage/504.
convert-im6.q16: no images defined `INLINE:GIF:-' @ error/convert.c/ConvertImageCommand/3258.
无法找出我错在哪里。使用 ImageMagick 时,相同的命令在本地系统上运行完美。如果有人能指出我正确的方向,我将不胜感激。
谢谢!
仔细查看命令行和错误信息。这就是您作为 URL:
传递的内容
注意末尾的 "null:"。这不太可能是你 URL 的一部分。事实证明,我认为您传递命令参数的方式也不正确。通常,您在传递给 spawn
的数组中分别传递每个参数。这意味着您应该将每个标志和每个标志的值分开作为单独的数组元素。它应该更像你在 documentation for spawn.
中看到的样子
我想在 gif 上写一些文本,然后将其转换为 base 64。但是我遇到了一些我无法解决的错误。我在 Internet 上找到了一些示例,但它们都使用非基于 URI 的本地临时文件。
这是我在我的函数中所做的:
var spawnPromise = spawn(
'convert',
[
`"https://firebasestorage.googleapis.com/v0/b/blizquiz-d9ee2.appspot.com/o/animations%2Fthe-score%2Fbanana.gif?alt=media&token=5c44b0b4-7238-40a3-8ab5-42889781bf60" null:`,
`-fill '#000000' -font "https://firebasestorage.googleapis.com/v0/b/blizquiz-d9ee2.appspot.com/o/animations%2Fthe-score%2FChalkboardSE.ttf?alt=media&token=d83eadaf-9b81-4290-aa12-be6492f0243b" -pointsize 60 -annotate +270+530 '26%'`,
`-layers composite -layers Optimize INLINE:GIF:-`,
],
{capture: ['stdout', 'stderr']},
);
我收到的错误日志:
stderr: convert-im6.q16: unable to open image `"https://firebasestorage.googleapis.com/v0/b/blizquiz-d9ee2.appspot.com/o/animations%2Fthe-score%2Fbanana.gif?alt=media&token=5c44b0b4-7238-40a3-8ab5-42889781bf60" null:': No such file or directory @ error/blob.c/OpenBlob/2701.
convert-im6.q16: no decode delegate for this image format `GIF?ALT=MEDIA&TOKEN=5C44B0B4-7238-40A3-8AB5-42889781BF60" NULL:' @ error/constitute.c/ReadImage/504.
convert-im6.q16: unrecognized option `-fill '#000000' -font "https://firebasestorage.googleapis.com/v0/b/blizquiz-d9ee2.appspot.com/o/animations%2Fthe-score%2FChalkboardSE.ttf?alt=media&token=d83eadaf-9b81-4290-aa12-be6492f0243b" -pointsize 60 -annotate +270+530 '26%'' @ error/convert.c/ConvertImageCommand/1673.
更新 根据收到的反馈,我修改了代码
var spawnPromise = spawn(
'convert',
[
`"https://firebasestorage.googleapis.com/v0/b/blizquiz-d9ee2.appspot.com/o/animations%2Fthe-score%2Fbanana.gif?alt=media&token=5c44b0b4-7238-40a3-8ab5-42889781bf60"`,
`-fill`,
`#000000`,
`-font`,
`"https://firebasestorage.googleapis.com/v0/b/blizquiz-d9ee2.appspot.com/o/animations%2Fthe-score%2FChalkboardSE.ttf?alt=media&token=d83eadaf-9b81-4290-aa12-be6492f0243b"`,
`-pointsize`,
`60`,
`-annotate`,
`+270+530`,
`26%`,
`-layers`,
`composite`,
`-layers`,
`optimize`,
`INLINE:GIF:-`,
],
{capture: ['stdout', 'stderr']},
);
但仍然出现相同的错误,尽管在本地执行时它工作正常。
stderr: convert-im6.q16: unable to open image `"https://firebasestorage.googleapis.com/v0/b/blizquiz-d9ee2.appspot.com/o/animations%2Fthe-score%2Fbanana.gif?alt=media&token=5c44b0b4-7238-40a3-8ab5-42889781bf60"': No such file or directory @ error/blob.c/OpenBlob/2701.
convert-im6.q16: no decode delegate for this image format `GIF?ALT=MEDIA&TOKEN=5C44B0B4-7238-40A3-8AB5-42889781BF60"' @ error/constitute.c/ReadImage/504.
convert-im6.q16: no images defined `INLINE:GIF:-' @ error/convert.c/ConvertImageCommand/3258.
无法找出我错在哪里。使用 ImageMagick 时,相同的命令在本地系统上运行完美。如果有人能指出我正确的方向,我将不胜感激。 谢谢!
仔细查看命令行和错误信息。这就是您作为 URL:
传递的内容注意末尾的 "null:"。这不太可能是你 URL 的一部分。事实证明,我认为您传递命令参数的方式也不正确。通常,您在传递给 spawn
的数组中分别传递每个参数。这意味着您应该将每个标志和每个标志的值分开作为单独的数组元素。它应该更像你在 documentation for spawn.