Reputation: 50019
I'm using ImageMagick to generate some product badges for products in our system. Product badges are like SO flair, just a few composite images and some text. There is nothing wrong with the script as it runs fine on my development machine which runs Windows. However, on my production system (CentOS 5.1), it renders everything except the text.
I thought this was a font issue, but it doesn't work even if I copy the font file to the PHP file location nor did it work when I gave it a full path.
And it didn't work when I installed the Windows fonts for Linux as described here.
I've typed convert -list font
and it shows a list of fonts that Imagick knows about (parital list shown below)
Font: Times-BoldItalic
family: Times
style: Italic
stretch: Normal
weight: 700
glyphs: /usr/share/fonts/default/Type1/n021024l.pfb
Font: Times-Italic
family: Times
style: Italic
stretch: Normal
weight: 400
glyphs: /usr/share/fonts/default/Type1/n021023l.pfb
Font: Times-Roman
family: Times
style: Normal
stretch: Normal
weight: 400
glyphs: /usr/share/fonts/default/Type1/n021003l.pfb
I tried giving the absolute path listed here and it didn't work. I also tried just using the name and still nothing.
Basically the image shows up, but the text parts of it don't show up at all and no errors are thrown (see images below).
There's nothing wrong with the code and both Windows and CentOS are running close versions of Imagick (6.7.1-4 and 6.7.1-3). The only issue could be the font, I'm just putting normal TTF fonts up and testing, do I need some kind of special font to get it to work?
Working
Broke
EDIT - Ignore the differences in the QR code and the ratings. This is due to the working badge and the non working badge being on two different servers.
UPDATE 1 - I've run a simple test script and even that doesn't work. This is what I ran as a test : https://www.php.net/manual/en/function.imagick-annotateimage.php The font just doesn't show up and no errors are thrown.
I've also copied a font from the CentOS system and tried it on the Windows box and it works fine. Fonts simply don't seem to work on CentOS.
I've also tried it without setting a font, I assume Imagick picks up a default font or something, and again works on Windows, but not on CentOS. I'm going to try this on a different *nix version to see what happens. Will update with findings.
Update 3 : I've narrowed the issue down to a problem with the FreeType library I think. The forums say that FreeType needs to be installed for text to be displayed properly. And when I look at the config.log it tells me that there is an issue installing FreeType. Any heads up on this would be appreciated, meanwhile I'm going to re-install Freetype and run the installation again.
Upvotes: 3
Views: 1214
Reputation: 3023
You can't just install Freetype. You actually have to install Freetype on your server, then recompile ImageMagick using the --with-freetype-dir=/usr/local option. Where /usr/local is the path to your Freetype install.
I believe it's normally /usr/local/bin
Give that a whirl and let us know what happens ;)
Upvotes: 1