How to perform "tile:" command with im4java?

160 Views Asked by At

I'm trying to use im4java to generate sample image with text on image with the pattern. My code:

    ConvertCmd convertCmd = new ConvertCmd();

    IMOperation imOperation = new IMOperation();
    imOperation.size(564, 564);
    imOperation.tile(patternImg);
    imOperation.background("none");
    imOperation.stroke("black");
    imOperation.strokewidth(2);
    imOperation.fill("white");
    imOperation.gravity("center");
    imOperation.pointsize(40);
    imOperation.border(3, 3);
    imOperation.label(generateImageRequestDTO.getMainText());
    imOperation.composite();
    imOperation.addImage(absolutePathWorkDir + "/" + "test.jpg");
    convertCmd.run(imOperation);

Which generate such script:

convert \
   -size "564x564" -tile "/var/images/patterns/1.jpg" \
  -background "none"-stroke "black" -strokewidth "2" -fill "white" \
  -gravity "center"-pointsize "40" -border "3x3" -label "This is some text" \
  -composite "/var/images/workdir/test.jpg"

Which is almost what I need. This is the code which I'm trying to generate:

convert \
   -size "564x564" tile:"/var/images/patterns/1.jpg" \
  -background "none"-stroke "black" -strokewidth "2" -fill "white" \
  -gravity "center"-pointsize "40" -border "3x3" label:"This is some text" \
  -composite "/var/images/workdir/test.jpg"

Basiclly

  • -tile ==> tile:
  • -label ==> label:

what i'm missing here?

1

There are 1 best solutions below

0
On

Thank You a lot @emcconville ! That works!

Try adding the tile: & label: prefix to imOperation.addImage method. Like imOperation.addImage("tile:"+patternImg); – emcconville