Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Imagemagick fonts not found in OSX

When trying to add annotations to images in ImageMagick, It failed with the following message:

convert: unable to read font `(null)' @ error/annotate.c/RenderFreetype...

How do I make Imagemagick find these fonts?

like image 457
Adam Matan Avatar asked Dec 15 '22 12:12

Adam Matan


2 Answers

The solution that worked for me was given by Neville in this post:

  1. Create an imagemagick configuration folder: mkdir ~/.magick
  2. Save this Perl script as /tmp/script.pl
  3. Make the script executable: chmod +x /tmp/script.pl
  4. Run the script locally and redirect the output to the file type.xml in ~/.magick: /tmp/script.pl > ~/.magick/type.xml

This solved the fonts problem, while installing fondu, the imagemagick pkg file and some other tricks didn't.

Great! Now I can annotate some flickr cats with the image size and resolution (I want this for finding the optimal resolution for an app I'm working on).

enter image description here

enter image description here

enter image description here

like image 131
Adam Matan Avatar answered Dec 17 '22 02:12

Adam Matan


Adopting Adam Matan's answer, here's how I got this to work with imagemagick 7+ on macOS 10.12+ installed with homebrew. (This also assumes you have perl installed.)

  1. Download the perl script and save it to /usr/local/bin/imagick_type_gen

  2. Make the script executable:

    • chmod +x /usr/local/bin/imagick_type_gen
  3. Find the font path for imagemagick by running convert -list font | grep Path. This should return where imagemagick is looking for fonts. The Apple path for me was this:

    • /usr/local/Cellar/imagemagick/7.0.7-22/etc/ImageMagick-7/type-apple.xml
  4. Run imagick_type_gen and direct the output to the path above:

    • imagick_type_gen > /usr/local/Cellar/imagemagick/7.0.7-22/etc/ImageMagick-7/type-apple.xml
  5. Run convert -list font | less to see the font names imagemagick will use, e.g., some fonts will be labeled as GeorgiaB instead of Georgia Bold. (hit q to quit)

imagemagick should now see the fonts you have installed on the your system.

like image 39
aboutaaron Avatar answered Dec 17 '22 00:12

aboutaaron