Cannot add text to my image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
donslund
Posts: 7
Joined: 2012-06-11T01:23:00-07:00
Authentication code: 13

Cannot add text to my image

Post by donslund »

I cannot add text to my image.

This works fine, it draws the bezier.
exec("convert julekort/".$row["image"].".jpg -draw 'bezier 70,50 95,100 95,0 120,50' flower_annotate1.jpg");

But this writes no text
exec("convert julekort/".$row["image"].".jpg -draw \"text 100,100 'Works like magick!' \" flower_annotate1.jpg");

I have also tried to use annotate with no luck.

Could the host have blocked for working with text?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Cannot add text to my image

Post by Bonzo »

The text might be off your image; try this:

Code: Select all

exec("convert julekort/".$row["image"].".jpg -gravity center -draw \"text 0,0 'Works like magick!' \" flower_annotate1.jpg"); 
donslund
Posts: 7
Joined: 2012-06-11T01:23:00-07:00
Authentication code: 13

Re: Cannot add text to my image

Post by donslund »

Sorry, still no text. I suppose this should put the text right in the middle og the image. I only get the Background-image.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Cannot add text to my image

Post by fmw42 »

try with just one specific image hard coded in the command. perhaps it relates to your code for extracting the correct image or somewhere else in your code

try removing the space between the single and escaped double quote, though I would not expect that to be an issue.

Code: Select all

magick!' \" 
also try escaping the !

Code: Select all

magick\!'\" 
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Cannot add text to my image

Post by snibgo »

I would first try an example with no spaces or punctuation. Then you (probably) don't need quotes or escapes in the string. Like this, at the command line:

Code: Select all

convert -size 100x100 xc: -draw "text 50,50 hello" h.png
snibgo's IM pages: im.snibgo.com
donslund
Posts: 7
Joined: 2012-06-11T01:23:00-07:00
Authentication code: 13

Re: Cannot add text to my image

Post by donslund »

exec("convert -size 100x100 xc: -draw 'text 50,50 hello' h.png"); just gives me a white image size 100x100px. So the text part doesn't work, ata least not on my server.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Cannot add text to my image

Post by fmw42 »

What version of IM are you using and on what platform? Perhaps it is time for an upgrade. Your version may have a bug?
donslund
Posts: 7
Joined: 2012-06-11T01:23:00-07:00
Authentication code: 13

Re: Cannot add text to my image

Post by donslund »

ImageMagick 6.6.7-1 2011-01-17

PHP Version 5.3.8
donslund
Posts: 7
Joined: 2012-06-11T01:23:00-07:00
Authentication code: 13

Re: Cannot add text to my image

Post by donslund »

I tested on another server with af slightly newer ImageMagisk, and there it works. I will move the files.

Thanks.
Post Reply