Page 1 of 1

ImageMagick wont write text over images

Posted: 2008-09-29T22:29:34-07:00
by dankind
The syntax I'm using is:

Code: Select all

convert \
-font "./verdana.ttf" \
-fill "#101411" -pointsize 33 -gravity "West" \
-draw "text 1,0 'foobar'" \
bg.png \
text.png
This works fine on my debian installation... IM 6.2.4. It is not working on my RHEL installation. I've tried with the yum version (6.2.8).

I've also tried compiling from source -- the same version as my debian box.. 6.2.4, as well as 6.4.4-10.. both of which don't work.

Anyone have any idea what might be wrong/missing? 'convert' does not throw any errors, only it doesn't add the text to the image.

Any help would be greatly appreciated

Dan

Re: ImageMagick wont write text over images

Posted: 2008-09-30T09:07:55-07:00
by el_supremo
Try rearranging the command slightly.

Code: Select all

convert \
bg.png \
-font "./verdana.ttf" \
-fill "#101411" -pointsize 33 -gravity "West" \
-draw "text 1,0 'foobar'" \
text.png
Pete

Re: ImageMagick wont write text over images

Posted: 2008-09-30T10:20:34-07:00
by dankind
el_supremo,

Thanks for the reply, however it produces the same result. It just writes bg.png into text.png and none of the text is displayed. No errors are given either. If I add the -verbose option, it returns:

bg.png=>text.png PNG 200x35 2000x350+179+216 DirectClass 14kb

If I run:

Code: Select all

convert \
-size 200x35 \
xc:lightblue \
-font "/var/www/html/main/simg/verdana.ttf" \
-fill "#101411" -pointsize 33 -gravity "West" \
-draw "text 1,0 'foobar'" \
-verbose \
text.png
bg.png:

Image

It works fine and prints the text to text.png. But I just can't seem to get it to write on top of the image.

Re: ImageMagick wont write text over images

Posted: 2008-09-30T10:34:12-07:00
by el_supremo
The problem is with your bg.png image. If you identify it you get this info:

Code: Select all

bg.png PNG 200x35 2000x350+179+216 8-bit DirectClass 13.6kb
This means that the basic 200x35 image that you see is actually on a much larger 2000x350 canvas.
You can remove it with +repage:

Code: Select all

convert \
bg.png \
+repage \
-font "./verdana.ttf" \
-fill "#101411" -pointsize 33 -gravity "West" \
-draw "text 1,0 'foobar'" \
bg_text.png
Pete

Re: ImageMagick wont write text over images

Posted: 2008-09-30T11:13:16-07:00
by dankind
el_supremo,

You rock! I spent 5 hours last night racking my brain over this one. Thank you

Re: ImageMagick wont write text over images

Posted: 2008-10-01T18:28:23-07:00
by anthony
I would check you bg.png generator, and posibly add a +repage to it.

WARNING: viewing the image in a browser would probably (depends on the browser) have shown you this problem).


In summery. While normally PNG will NOT save virtual canvas size information, it does save virtual canvas offset information, and if present, IM will try to generate a 'canvas size' that is appropriate for that offset and image size.

However IM generated PNG images can save virtual canvas size meta data, so that such images can be used as intermediate layer images. Of course this size information is only available to IM commands, and not to other PNG viewers.

I have re-written IM examples section on PNG and the Virtual Canvas to try and make this clearer.