ImageMagick wont write text over images

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
dankind

ImageMagick wont write text over images

Postby dankind » 2008-09-29T22:29:34-07:00

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

el_supremo
Posts: 987
Joined: 2005-03-21T21:16:57-07:00

Re: ImageMagick wont write text over images

Postby el_supremo » 2008-09-30T09:07:55-07:00

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

dankind

Re: ImageMagick wont write text over images

Postby dankind » 2008-09-30T10:20:34-07:00

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.

el_supremo
Posts: 987
Joined: 2005-03-21T21:16:57-07:00

Re: ImageMagick wont write text over images

Postby el_supremo » 2008-09-30T10:34:12-07:00

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

dankind

Re: ImageMagick wont write text over images

Postby dankind » 2008-09-30T11:13:16-07:00

el_supremo,

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

User avatar
anthony
Posts: 8736
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia
Contact:

Re: ImageMagick wont write text over images

Postby anthony » 2008-10-01T18:28:23-07:00

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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
http://www.imagemagick.org/Usage/


Return to “Bugs”

Who is online

Users browsing this forum: No registered users and 4 guests