Using ImageMagick with PHP

Written by Shanx May 27th, 2003

Using ImageMagick with PHP

Continue reading →
Close

There is a PHP module for Imagemagick, called imagick, sort of like the one for GD.

Following is some simple 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");

Posted in Miscellaneous

7 Comments

Tagged with

7 Comments

  1. superD says:

    would it be possible that you may make it a bit more specific for the non-programmers??
    such as “save as” and the next next step…etc??
    if it’s possible would be great, love to use it on my site. Thanks!

  2. Vince says:

    There are more in-depth examples about how to use the IMAGICK PHP extension here:

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

    The Samples/ directory contains about 30 examples on how you can use IMAGICK

    -Vince
    Biosonik.com

  3. Ben says:

    I think you are right. One neat thing, I\’d have never predicted with the internet, is that the sites are staying around, so that people can find them, read them and learn from them. The worst thing about the .edu internet was data rot (a form of link rot) where resources and knowledge went into the vapor every semester.

  4. blub says:

    But what good are websites and references, if the software in question is not being actively developed. The imagick modul for example has so many bugs and glitches, and it seems that no one is taking care of it. So I wish someone would update all those websites, instead of them still being there, pointing to the same old (outdated) information.

  5. [...] Re: Imagemagick / apache / php According to this, the PHP interface is called imagick, not Imagemagick. Though the latter is probably also required. Zypper show no such package called imagick in the repos so you may have to build your own from PEAR. Or maybe there is an OpenSUSE repo with it pre-built. Using ImageMagick with*PHP | Sniptools | [...]

  6. Webagentur says:

    Thank you, this little tut has me very helped.

  7. [...] Using ImageMagick with PHP | Sniptools | Miscellaneous (tags: php imageslicing) [...]

Leave a Reply

Miscellaneous

I use the Nokia e61i as my mobile. Instead of my telco’s data plan (which offers me a meagre 1GB per month) I simply prefer to use my home wireless [...]

Continue reading →

View all

Web Tools

If you use Firefox (and if not, what are you waiting for?) you are familiar with useful extensions such as Video Downloader, which allow you to save local copies of [...]

Continue reading →

View all

Databases

This regexp worked for me. SELECT * FROM table WHERE NOT column ~ ( ‘^(‘|| $$[\09\0A\0D\x20-\x7E]|$$|| — ASCII $$[\xC2-\xDF][\x80-\xBF]|$$|| — non-overlong 2-byte $$\xE0[\xA0-\xBF][\x80-\xBF]|$$|| — excluding overlongs $$[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|$$|| — straight 3-byte [...]

Continue reading →

View all

Windows

So you’ve been visited by the much dreaded CRC — Cyclical Redundancy Check error, most likely encountered while copying files between hard disks. On Mac OSX, this will usually appear [...]

Continue reading →

View all

Mac OSX

A simple app ought to do it. Download iRinger. It’s a Windows app. If you’re on Mac, you’ll want to use it within a virtual machine, like Parallels or VMWare [...]

Continue reading →

View all

System Maintenance

I use the Nokia e61i as my mobile. Instead of my telco’s data plan (which offers me a meagre 1GB per month) I simply prefer to use my home wireless [...]

Continue reading →

View all

Wordpress

Among many new exciting features, WordPress 2.6 released the ability to store each and every revision of your posts, like an elaborate update history. Now this can be a pretty [...]

Continue reading →

View all

Audio/Video

Panic, the makers of some fantastic software such as Transmit or Panic, also have the most light-weight audio converter for the Mac OSX platform. It’s called Audion: get it here. [...]

Continue reading →

View all

iPhone

A simple app ought to do it. Download iRinger. It’s a Windows app. If you’re on Mac, you’ll want to use it within a virtual machine, like Parallels or VMWare [...]

Continue reading →

View all