My question is straight forward. I have recently started using Im4Java, an imagemagick java wrapper, and was wondering if the API supports adding text to images. If it does, does it allow the specification of font-size, font, and color. Is there a method part of the API that supports this? If not, what might be an open source alternative?
Asked
Active
Viewed 976 times
1 Answers
4
Some one must really hate me based off the downvoting across multiple questions of mine. Anyway, I have found the methods in Im4Java's API and am posting the code with comments:
public void annotateImage()
{
IMOperation op = new IMOperation(); //imagemagick operator for command line tools
//draw method
op.addImage(); //input image
op.resize(957, 626); //resizing image
op.pointsize(20); //size of text
op.font("Times-New-Roman"); // font
op.fill("Black"); //font color
op.draw("text 500,300 'works like magic!'"); // location of text, actual text
op.addImage();// output image
ConvertCmd cmd = new ConvertCmd(); //using the convert command from imagemagick
cmd.setSearchPath("C:\\Program Files (x86)\\ImageMagick-6.8.9-0"); //commands location
FilenamePatternResolver resolver = new FilenamePatternResolver("%P/%f.jpg");
try {
cmd.run(op, "dest\\input.jpg", resolver.createName("dest\\output.jpg"));
} catch (Exception e)
{
e.printStackTrace();
}
}

antihero989
- 486
- 1
- 10
- 32