[thelist] Convert Text to Image in PHP

Bob Meetin bobm at dottedi.biz
Mon Dec 15 13:55:25 CST 2008


Fred Jones wrote:
>> ImageMagick should be able to do this via convert. I played with creating text a while go just to see, but didn't have a live need.
>>
>> http://www.imagemagick.org/Usage/text/
>>
>> convert -background floralwhite -fill "#568100" -size 200x label:"Fred Jones" fred_jones.png
>>
>> convert -background floralwhite -fill "#568100" -size x100 label:"Fred Jones" fred_jones2.png
> 
> This is great. Works wonderfully from the command line. I found append
> also and am getting what I need.
> 
>> in PHP:
>>
>> you can use system
>>
>> system ("convert ...");
> 
> This didn't work out of the box, but I can fix that probably.
> 
> Only issue thus far is that quality of the image isn't that great. I'm
> not sure if it's the rendering or the fonts or both. I am going to
> play with GD also and see if I can get better.
> 
> Thank you very much for that 'copy and paste' code--really sent me in
> the right direction.
> 
> Thanks,
> Fred
> 
> 

Quality you say? I am not sure. Maybe my eyes need a 640x480 monitor or I should turn the monitor on.

With .jpg you can use "-quality 70" and get pretty good quality.

If your .jpg images are too hefty you may need "-strip" which strips off some weighty profile baggage.  this is almost a necessity if you use the -quality 
option on a jpg.  otherwise you "will" end up with images heavier than the original.

with .pngs I did some playing with "-depth" such as "-depth 8". Quality seems fine and images much less hefty.  I also tested -6 and -4 which makes for almost 
light images.

I use 'append' with this utility: http://www.dottedi.biz/tools/banner_image_maker.php



More information about the thelist mailing list