Reputation: 4785
I am trying to write some text over a gif and then convert it into base 64. But I am getting some error which I am not able to resolve. I found some examples on internet but all of them are using local temp files not URI based.
Here is what I am doing in my functions:
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']},
);
The Error Log which I am getting:
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.
Update Based on the feedback I got, I modified the code
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']},
);
But still getting below the same error, although it works fine when executed locally.
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.
Not able to figure out where I am wrong. The same command works perfectly on the local system when using ImageMagick. I would be grateful if anyone can point me in the right direction. Thanks!
Upvotes: 0
Views: 262
Reputation: 317657
Look at the command line and error message very carefully. This is what you're passing as a URL:
Note the "null:" at the end. That's not likely part of your URL. It turns out, I think the way you are passing command parameters is also not correct. Typically you pass each argument separately in the array that you pass to spawn
. This means you should probably separate out each flag and the value of each flag as separate array elements. It should be more like how you see in the documentation for spawn.
Upvotes: 1