0

我正在尝试使用 im4java 生成带有图案的图像上的文本示例图像。我的代码:

    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);

生成这样的脚本:

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"

这几乎是我需要的。这是我试图生成的代码:

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"

基本上

  • -瓷砖==>瓷砖:
  • -标签 ==>标签:

我在这里缺少什么?

4

1 回答 1

0

非常感谢@emcconville!这样可行!

尝试将 tile: & label: 前缀添加到 imOperation.addImage 方法。像 imOperation.addImage("tile:"+patternImg); –埃麦康维尔

于 2019-10-22T14:51:57.390 回答