Page 1 of 1

Best command to create a label below an image?

Posted: 2009-07-02T08:39:33-07:00
by yamaguchih
I am using ImageMagick commands as part of a Java application I am developing.

I want to do the following:

Inputs:
1. A JPEG file, of arbitrary length/width (But not smaller than, say, 500 x 500 pixels)
2. A text string, of an arbitrary length (but not super long. Maybe a paragraph at most.)

Outputs:
1. The JPEG file, which has a white 'band' appended to the bottom containing the text.
The original image's dimensions will definitely increase due to the added label.

2. The same JPEG file, which has the text displayed with a semi-transparent background
directly on top of the image, along the bottom side. The original image's dimensions will not change because
the text will simply be overlayed on it.

Now, I tried this using some FAQ I found online but the text always seems to overflow
from the image (and as a result I can only read part of it.)

Is there a way to get ImageMagick to figure out the right fontsize given an image width,
create the 'band' (label) separately with that fontsize and width, and append it to the original
image? I do understand that if we have a large space and short text, the text may become
huge and that's alright for now.

Thanks!

Re: Best command to create a label below an image?

Posted: 2009-07-02T09:30:26-07:00
by fmw42
see label: it will fill the text to the image size and pick the best pointsize if you don't specify the pointsize

http://www.imagemagick.org/Usage/text/#label

then you can append it below the other image using -append
http://www.imagemagick.org/script/comma ... php#append
http://www.imagemagick.org/Usage/layers/#append

You can also do the labeling below an image using montage
http://www.imagemagick.org/Usage/montage/#label

Re: Best command to create a label below an image?

Posted: 2009-07-02T20:56:16-07:00
by anthony
A large number of methods of annotating (labeling) images in various ways are listed in IM Examples, Annotating Images.
http://www.imagemagick.org/Usage/annotating/

WARNING: reading JPEG and then saving back to JPEG will degrade the image.
This is because JPEG is a lossy format. Best idea is to start with the original image and only save the final image to JPEG. do not use JPEg for intermediate image processing!

See JPEG Format
http://www.imagemagick.org/Usage/formats/#jpg