Simple Text Label Examples Fails

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?".
Greg Coats
Posts: 31
Joined: 2004-10-28T11:18:28-07:00
Location: Virginia, USA

Simple Text Label Examples Fails

Post by Greg Coats »

I am following the first official ImageMagick text example posted http://www.cit.gu.edu.au/~anthony/graph ... ick6/text/ called Label - Simple Text Label, and using the current version of ImageMagick, but the example fails. Can someone please show me a successful example of drawing text to a raster image?

$ convert -version
Version: ImageMagick 6.2.8 07/07/06 Q8 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2006 ImageMagick Studio LLC

$ convert -background lightblue -fill blue -font Candice -pointsize 72 label:Anthony label.gif
sh: line 1: gs: command not found
sh: line 1: gs: command not found
convert: unable to read font `Candice'.
convert: no decode delegate for this image format `/var/tmp/magick-VV0hazky'.
convert: Postscript delegate failed `/var/tmp/magick-VV0hazky'.
convert: missing an image filename `label.gif'.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

To annotate an image you need to build ImageMagick with the Freetype delegate library without it ImageMagick will use Ghostscript to render fonts. Type
  • identify -list format
What you want is a line similar to this:
  • TTF* TTF r-- TrueType font (Freetype 2.1.10)
Without it you will need to install Ghostscript on your computer but the font rendering may not be as good or accurate as with Freetype.
Greg Coats
Posts: 31
Joined: 2004-10-28T11:18:28-07:00
Location: Virginia, USA

Post by Greg Coats »

Running the identify -list format command as you suggest shows that my ImageMagick can access several font collections. But when following the ImageMagick text example, I still get the same error I originally posted, and I remain unable to use ImageMagick to draw text in a raster image. Can someone please demonstrate the syntax for drawing text?

identify -list format | grep font
OTF* TTF r-- Open Type font (Freetype 2.2.1)
PFA* TTF r-- Postscript Type 1 font (ASCII) (Freetype 2.2.1)
PFB* TTF r-- Postscript Type 1 font (binary) (Freetype 2.2.1)
TTC* TTF r-- TrueType font collection (Freetype 2.2.1)
TTF* TTF r-- TrueType font (Freetype 2.2.1)
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Post by el_supremo »

Looks like you haven't got the Candice font.
Try it with:
-font courier-new

or:
-font times-new-roman

Best Wishes
Pete
Greg Coats
Posts: 31
Joined: 2004-10-28T11:18:28-07:00
Location: Virginia, USA

Post by Greg Coats »

I tried using -font courier-new and -font times-new-roman, but that continues to yield the same error message I originally reported on 11 July 2006. So, I still do not have any way to draw text with ImageMagick. Can someone demonstrate a convert command line that successfully draws text?

$ convert -background lightblue -fill blue -font courier-new -pointsize 72 label:Anthony label.gif
sh: line 1: gs: command not found
sh: line 1: gs: command not found
convert: unable to read font `courier-new'.
convert: no decode delegate for this image format `/var/tmp/magick-evm8uUyR'.
convert: Postscript delegate failed `/var/tmp/magick-evm8uUyR'.
convert: missing an image filename `label.gif'.

$ convert -background lightblue -fill blue -font times-new-roman -pointsize 72 label:Anthony label.gif
sh: line 1: gs: command not found
sh: line 1: gs: command not found
convert: unable to read font `times-new-roman'.
convert: no decode delegate for this image format `/var/tmp/magick-lLBxwQ9t'.
convert: Postscript delegate failed `/var/tmp/magick-lLBxwQ9t'.
convert: missing an image filename `label.gif'.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

ImageMagick defaults to Ghostscript if its does not include Freetype support. So either install Freetype and rebuild ImageMagick from source or install Ghostscript. Note, rendering text with Ghostscript is not as accurate as using the Freetype library.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Post by Bonzo »

I have just tried the example code and it worked Ok for me.

I would guess that the "gs" in these two lines relate to ghost script ?

sh: line 1: gs: command not found
sh: line 1: gs: command not found
Greg Coats
Posts: 31
Joined: 2004-10-28T11:18:28-07:00
Location: Virginia, USA

Post by Greg Coats »

ImageMagick identify -list format | grep font finds support for five Freetype 2.2.1 fonts, so convert should also be finding Freetype support. How do I get convert to use the Freetype fonts that identify finds?

identify -list format | grep font
OTF* TTF r-- Open Type font (Freetype 2.2.1)
PFA* TTF r-- Postscript Type 1 font (ASCII) (Freetype 2.2.1)
PFB* TTF r-- Postscript Type 1 font (binary) (Freetype 2.2.1)
TTC* TTF r-- TrueType font collection (Freetype 2.2.1)
TTF* TTF r-- TrueType font (Freetype 2.2.1)
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

See if you have more than one version of convert on your system. What does
  • convert
on the command line say its version is? We tried your command and it works fine for us (we used helvetica as the font and it used Freetype to render the text).
Greg Coats
Posts: 31
Joined: 2004-10-28T11:18:28-07:00
Location: Virginia, USA

Post by Greg Coats »

I actually posted the version of convert I am using in my initial posting on 11 July 2006. Here it is again.
convert -version
Version: ImageMagick 6.2.8 07/07/06 Q8 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2006 ImageMagick Studio LLC

Can you please post the exact convert command line that is successful for you?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

Try
  • convert -verbose -background lightblue -fill blue -font helvetica -pointsize 72 label:Anthony label.gif
If it shows an attempt to run Ghostscript, something is very screwy. It should always default to the Freetype renderer. If all else fails, try ImageMagick 6.2.9-0 being released in just a few hours.
Greg Coats
Posts: 31
Joined: 2004-10-28T11:18:28-07:00
Location: Virginia, USA

Post by Greg Coats »

That does not work for me :(
It is possible that to draw text under Mac OS X 10.4 requires different syntax?
Greg

convert -version
Version: ImageMagick 6.2.8 07/07/06 Q8 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2006 ImageMagick Studio LLC

identify -list format | grep font
OTF* TTF r-- Open Type font (Freetype 2.2.1)
PFA* TTF r-- Postscript Type 1 font (ASCII) (Freetype 2.2.1)
PFB* TTF r-- Postscript Type 1 font (binary) (Freetype 2.2.1)
TTC* TTF r-- TrueType font collection (Freetype 2.2.1)
TTF* TTF r-- TrueType font (Freetype 2.2.1)

convert -verbose -background lightblue -fill blue -font helvetica -pointsize 72 label:Anthony label.gif
sh: line 1: gs: command not found
sh: line 1: gs: command not found
convert: unable to read font `helvetica'.
convert: no decode delegate for this image format `/var/tmp/magick-vOk9C76c'.
convert: Postscript delegate failed `/var/tmp/magick-vOk9C76c'.
convert: missing an image filename `label.gif'.
kyngchaos

Post by kyngchaos »

I just gave the example a try (I built the IM that Greg is using). Part of the problem is locating the fonts. None of the normal OS X font paths are searched (/System/Library/Fonts, /Library/Fonts, ~/Library/Fonts) so just the font name is not enough. I found that when it couldn't find the font, I get the gs error.

Another part of the problem seems to be reading certain font formats. I could get otf and Windows flat ttf and pfb (PS) fonts to work, but Mac style TT and PS fonts and dfonts give me a simple 'unable to read font' error, no gs mess.

So, something is up with my build of FreeType - I've only really ever used OTF and flat TT fonts with my FreeType build. I'll look into it. And the font search path thing also.
kyngchaos

Post by kyngchaos »

Another possible source of the problem - for Mac type font packages (suitcases, dfonts) where more than one font face or style can be in a single file (I think OTF fonts can also have more than one), how does one specify the style within the file? ie /Library/Fonts/Arial contains regular, bold, italic and bold-italic. All these multi-face font packages are where the errors are happening.
Greg Coats
Posts: 31
Joined: 2004-10-28T11:18:28-07:00
Location: Virginia, USA

Post by Greg Coats »

Let's say I want to use the fixed width font Courier. Courier comes in 4 flavors, under Mac OS X.
Courier Regular
Courier Oblique
Courier Bold
Courier Bold Oblique
How do I tell ImageMagick which of these 4 flavors to use?

I would still like to see example syntax for using convert to draw text under Mac OS X. So far, everything we have tried has failed.
Post Reply