Page 1 of 1

Input Image + Text Overall is Outputing two image files

Posted: 2009-07-21T00:56:32-07:00
by Wizartar
I need some help with this command as it's creating two images on output, but really all that's required is to overall the text on the original image.

What it's meant to do

1. Resize InputImage.jpg to 229x172
2. Overall Text in the top center and wrap to multiple lines if required.
3. Output to a signle image to use on web

Code: Select all

convert InputImage.jpg -resize 229x172 -gravity north -fill blue -font arialbd.ttf -pointsize 18 -strokewidth 1.5 -compress jpeg -quality 65 -size 229x172 "caption:This is just some random text to test the wraping" OutputImage.jpg
This command created two images: {OutputImage-0.jpg, OutputImage-1.jpg}
0 is the Input Image resized
1 is the text

Is there an option I need to be using??? I'm new to ImageMagick, had all this working in PHP but GoDaddy only supports the 'convert' utility.

Re: Input Image + Text Overall is Outputing two image files

Posted: 2009-07-21T05:24:16-07:00
by anthony
First resize will fit the image into the size specified while preserving aspect ratio. That means one dimention may be smaller!!!

If you want exactly that size either use -resize 229x172\! OR
pad out the image with...
-gravity center -background blue -extent 229x172
after resizing the image.

See http://www.imagemagick.org/Usage/thumbnails/#pad
and http://www.imagemagick.org/Usage/resize/#noaspect


Next caption: creates an image!!! as such your command has two images when you try to save it. As JPEG can not save two images in one file, it add a -0 and -1 to the filename and create two separate files!!!!

To overly the text onto the resized image, add -background none before the caption: the add -composite or -flatten after it to merge the second (newer) image over the first. These are similar options but with different styles of handling, in this case go with -composite.

Re: Input Image + Text Overall is Outputing two image files

Posted: 2009-07-21T10:13:35-07:00
by Wizartar
Thanks Anthony!! :D

That sorted out the problem, removed the background then composite the text.

For anyone that's interested here's the final working command.

Code: Select all

convert InputImage.jpg -resize 229x172 -background none -gravity north -fill white -font arialbd.ttf -pointsize 18 -strokewidth 1.5 -stroke black -size 229x172 "caption:This is just some random text to test the wrapping" -composite -compress jpeg -quality 65 OutputImage.jpg