I can't overlay text on an 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
JimKerr

I can't overlay text on an image

Post by JimKerr »

Hi,

I want to overlay some text on an image and I wanted to use ImageMagick's annotate to do this.
On the first try to use this command, I got several errors about missing gs (Ghostscript).
I installed Ghostscript, but when I try to use annotate now, I get another error saying something like:
/usr/bin/convert: line 7: 11455 Bus error "$MAGICK_HOME/bin/$tool" "$@"
I'm using Mac OS/X, and I'm not used to Mac very much, so I'm not very good at working with Terminal and the commandline.

Could somebody please help me to fix this problem, so that I can use ImageMagick's annotate? Thanks!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: I can't overlay text on an image

Post by anthony »

Rather than relying of Ghostscript, use -font to specify a TTF file for the font.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
JimKerr

Re: I can't overlay text on an image

Post by JimKerr »

I specified the font and now it works.

Now I have another question. I want to write a list of prices on to a paper-like image.
What is the best way to write these prices under each other to the image?
Is there a way for -annotate to automatically write the next price in a new line with some spacing between?
And can it all be done in one annotate action or should there be more actions after each other to build the final image?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: I can't overlay text on an image

Post by Bonzo »

You can try using a text file with the prices in.

prices.txt

Code: Select all

£100.00
£0.99
£1.26

Code: Select all

convert background.jpg -annotate +0+0 @prices.txt output.jpg
Untested code ! You may not display the £ character and you might need to put the @prices.txt in ' ' e.g. '@prices.txt '

http://www.imagemagick.org/script/comma ... p#annotate
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: I can't overlay text on an image

Post by anthony »

The separate between the start points for each line is based on the fonts pointsize, at the current density. That is the offical meaning of 'pointsize' :-)


For 72 dpi density (the default in IM) then pointsize is in pixels! so the start of each line is 'pointsize' pixels below the previous. That is for 12 point add 12 to the Y value!

See IM examples,
Resolution, Pointsize, and Actual Font Size
http://www.imagemagick.org/Usage/text/#pointsize
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
JimKerr

Re: I can't overlay text on an image

Post by JimKerr »

The prices and the currency symbol are displayed, but now I want another font and this new font is not showing any text at all.
First I used the Arial font and specified it with -font Arial.ttf This worked well and all of the prices were showing correctly on the image.
Now I want to use this other font, and I have the ttf files for it, but when I try to use it nothing is showed on the image.
What could be the problem?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: I can't overlay text on an image

Post by Bonzo »

Imagemagick should find the fonts on your computer; try this to see what is regestered:

Code: Select all

convert -list font

OR

convert -list type
Depending on you version one will work and the other will not.

With -font try using the full path to your font.
JimKerr

Re: I can't overlay text on an image

Post by JimKerr »

the convert -list font command gives no output. The -list type command gives a list of color related terms.

The path should be correct, because the Arial.ttf and the other ttf are in the same folder.

I haven't tried any other fonts yet, but could it be that it's just the other font's ttf file that isn't recognized properly by IM, or something like that?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: I can't overlay text on an image

Post by Bonzo »

What version are you using ?

If convert -list font does not return anything that may be your problem.
JimKerr

Re: I can't overlay text on an image

Post by JimKerr »

I'm using IM 6.5.3-1 on Mac OS X.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: I can't overlay text on an image

Post by fmw42 »

Sounds like IM is not installed properly. Are you on Tiger or Leopard? Did you install manually or with MacPorts or Fink or from the binary?

You might want to review my notes/experience at: viewtopic.php?f=1&t=10442
Post Reply