Page 1 of 2

Simple Text Label Examples Fails

Posted: 2006-07-11T23:45:42-07:00
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'.

Posted: 2006-07-12T06:52:51-07:00
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.

Posted: 2006-08-11T04:47:20-07:00
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)

Posted: 2006-08-11T14:20:54-07:00
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

Posted: 2006-08-11T14:32:31-07:00
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'.

Posted: 2006-08-11T14:43:24-07:00
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.

Posted: 2006-08-11T14:45:23-07:00
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

Posted: 2006-08-11T15:40:48-07:00
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)

Posted: 2006-08-11T16:02:47-07:00
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).

Posted: 2006-08-11T16:15:09-07:00
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?

Posted: 2006-08-11T16:34:59-07:00
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.

Posted: 2006-08-11T17:44:06-07:00
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'.

Posted: 2006-08-11T18:48:42-07:00
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.

Posted: 2006-08-12T01:24:46-07:00
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.

Posted: 2006-08-14T00:36:33-07:00
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.