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?
The solution that worked for me was given by Neville in this post:
mkdir ~/.magick
/tmp/script.pl
chmod +x /tmp/script.pl
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).
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.)
Download the perl script and save it to /usr/local/bin/imagick_type_gen
Make the script executable:
chmod +x /usr/local/bin/imagick_type_gen
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
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With