I'm trying to use ImageMagick on an Ubuntu 12.04 server to create simple business cards dynamically. This is done via a php page. I tried to install MagickWand, but it didn't really work so I'm now using ImageMagick syntax and executing it via PHP function exec()
.
I'm making good progress, and had the basics more or less done, the output image looked okay and am now finetuning, setting the positions right, changing fonts and sizes, etc.
Our graphic person wants the text to be in Arial with bold titles, so I installed msttcorefonts on the server. Since then, the text in the output image is italic, and it ignores whatever font I use.
The curious thing is: if I echo the command to the page, copy and paste it into the ubuntu console, the image that's created there uses the right fonts and is exactly what I want.
So, it seems that when I execute the command via console, everything is fine, but when I execute it in PHP via exec()
, ImageMagick doesn't seem to recognize the fonts. Does anyone know why? Also, if it doesn't recognize the font, why does it default to italic, or, for that matter, why did the default change at all after installing the fonts?
This is the command I'm currently testing (with changed names and contact info):
convert \
-size 1051x697 \
xc:none \
-density 300 \
-fill white \
draw "rectangle 0,0 1051,697" \
-fill black \
-font Arial-Negreta \
-pointsize 9 \
-draw "text 140,175 'Hotel Example'" \
-font Arial-Normal \
-pointsize 6 \
-draw "text 140,220 'Example Street 8'" \
-draw "text 140,240 '12345 Exampletown'" \
-draw "text 140,280 'Telefon: 123 45 67 89 0'" \
-draw "text 140,300 'Fax: 234 56 78 90'" \
-draw "text 140,340 'http://www.example.de'" \
-draw "text 140,360 'hotel-example@example.de'" \
-stroke none -fill orange -draw "rectangle 1,32 1050,75" \
-fill grey \
-draw "rectangle 1,75 1050,100" \
-fill orange \
-draw "rectangle 1,626 1050,665" \
test_front.png
Edit:
I just noticed that running the command from the Ubunut console also only works in my home directory, and not in my /var/www directory. As APiK pointed out, it's probably a user thing.