0

I'm trying to generate following image: enter image description here

this is my code. I'm using out command to set fix with to font:


    const gm = require("gm").subClass({ imageMagick: true });
    gm(1800, 2400, "transparent")
      .fill("#ffffff")
      .drawRectangle(400, 400, 1400, 1400)
      .font("ananda.ttf", 90)
      .background("transparent")
      .out(
        "-size",
        "1600",
        "-gravity",
        "center",
        "caption: very very very long text very very very long text long long",
        "-geometry",
        "+0+400",
        "-composite"
      )
    
      .write("drawing.png", function (err) {
        if (err) return console.dir(arguments);
        console.log(this.outname + " created  :: " + arguments[3]);
      });

but when I'm trying to add .composite(foregroundImagePath) before or after out, it's not working.

'0': Error: Command failed: composite: unrecognized option-fill' @ error/composite.c/CompositeImageCommand/1021.`

  1. is there better way to rather use out command?
  2. how to add final picture to the image?
Lasharela
  • 1,307
  • 1
  • 11
  • 23
  • Composite requires 2 input images and an output image. I only see you creating the text image. So there is no second image for the composite until you provide your art image. Sorry, I do not know gm, only Imagemagick command line. – fmw42 Feb 28 '23 at 02:36
  • gm works perfectly with single argument. ```const backgroundImagePath = "canvas.png"; const foregroundImagePath = "image.png"; gm(backgroundImagePath) .composite(foregroundImagePath) .write("final.png", function (err) { if (err) return console.dir(arguments); console.log(this.outname + " created :: " + arguments[3]); });``` but any maybe any hints how to do this only with out command? – Lasharela Feb 28 '23 at 03:03
  • Post your input art image and your font file. I can only show you in Imagemagick command line, not gm. – fmw42 Feb 28 '23 at 03:15

0 Answers0