Set fixed width to image with ImageMagic library

37 views Asked by At

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?
0

There are 0 answers