Using ImageMagick with PHP

There is a PHP mod­ule for Imagemag­ick, called imag­ick, sort of like the one for GD.

Fol­low­ing is some sim­ple code that has worked for me:

if(!extension_loaded('imagick')) { dl('imagick.so'); }
$handle = imagick_create();
imagick_set_attribute($handle,array("quality"=>1,"magick"=>"png"));
imagick_set_attribute($handle,"size","98x20");
imagick_read($handle,"xc:#cccccc");
imagick_annotate($handle,array(
"primitive"     =>  "text 10,14 hello",
"pointsize"     =>  16,
"antialias"     =>  1,
"stroke"        =>  "#000000",
"font"          =>  "arial.ttf"
));
$handle = imagick_copy_rotate ($handle, 270);
header("Content-type: image/png");
imagick_dump($handle,"png");
  • superD

    would it be pos­si­ble that you may make it a bit more spe­cific for the non-programmers??
    such as "save as" and the next next step…etc??
    if it's pos­si­ble would be great, love to use it on my site. Thanks!

  • Vince

    There are more in-depth exam­ples about how to use the IMAGICK PHP exten­sion here:

    http://pecl.php.net/get/imagick-0.9.11.tgz
    http://pecl.php.net/package/imagick

    The Samples/ direc­tory con­tains about 30 exam­ples on how you can use IMAGICK

    –Vince
    Biosonik.com

  • Ben

    I think you are right. One neat thing, I\'d have never pre­dicted with the inter­net, is that the sites are stay­ing around, so that peo­ple can find them, read them and learn from them. The worst thing about the .edu inter­net was data rot (a form of link rot) where resources and knowl­edge went into the vapor every semester.

  • blub

    But what good are web­sites and ref­er­ences, if the soft­ware in ques­tion is not being actively devel­oped. The imag­ick modul for exam­ple has so many bugs and glitches, and it seems that no one is tak­ing care of it. So I wish some­one would update all those web­sites, instead of them still being there, point­ing to the same old (out­dated) information.

  • Pingback: Imagemagick / apache / php - openSUSE Forums()

  • http://typo3-agentur.typo3-fanworld.de Webagen­tur

    Thank you, this lit­tle tut has me very helped.

  • Pingback: links for 2010-01-20 « ueXpected()

  • http://scriptsnest.co.cc/ mayank

    how to install it on a webhost..do i have to ask them to install it for me