1

I'm trying to overlay text on top of a GIF using the gm package. It does overlay the text on top of regular images, however on GIFs it just overlays the last 2 frames. I don't have much experience using this package and Imagemagick.

Here's the code that edits the image.

gm(request(image)) //any image url
            .command('convert')
            .coalesce()
            .font("./impact.ttf")
            .dither(false)
            .fontSize(Math.round(width/11)) //Width is defined earlier in the code
            .stroke("#000000")
            .strokeWidth(width/450)
            .out('-gravity', 'north')
            .out('-size',width+'x','-fill','white','-background', 'transparent', '0')
            .out('caption:' + meme[0].toUpperCase().substr(meme[0].indexOf(" ")+1))
            .out('-layers','optimize')
            .out('-gravity', 'south')
            .out('-size',width+'x','caption:' + meme[1].toUpperCase())
            .out('-layers','optimize')
            .strip()
            // If i use these two, it does append all the layers but the text does not wrap like it does using caption
            // .drawText(0,1, meme[0].toUpperCase().substr(meme[0].indexOf(" ") + 1), 'North')
            // .drawText(0,0, meme[1].toUpperCase(), 'South')
               .stream((error, stdout) => {...}

Result of the code

Any help would be appreciated!

0 Answers0