Last updated: January 17, 2015 at 20:47 pm
small (hopefully) helpful article. It took me at least 3-4 hours to find a solution to get this going. All just to bring Lychee to work with Imagemagick. It’s exactly what I needed to manage some of my images and I think that Imagemagick (which is already used, no changes needed) is the faster solution to the PHP command imagecopyresampled. I did not yet verify speed or quality differences (yet) though, just a little project I wanted to try.
I had two mayor issues while trying to get Imagemagick running. The first was to find a php_*.dll which was compiled for a Imagemagick version which wasn’t 3 years old. Turns out there’s only one website out of the references left, which is still developing those: Imagick by PECL.
If you choose to download the DLL version you will get a bunch of files, of which you just need the php_imagick.dll
The second issues was to the find the Imagemagick-Version which the DLL was compiled with. I nearly lost it, because the DLL wouldn’t properly load to give me more info in the phpinfo(). As I tend to do in this situation I turn the volume of my music up and try to think of a solution. Turns out I’m really stupid sometimes. The “recycle” doesn’t do much for PHP, which should’ve been obvious because I stumbled across this a few times. Get your Powershell up and use “IISreset” after you flung the file into the /ext folder and edited your php.ini to include that extension:
[ExtensionList] extension=php_mysqli.dll ;Here should be more than this [PHP_IMAGICK] extension=php_imagick.dll
If you don’t want or can’t use IISreset, get a commandline, browse to the PHP-Installdir and use
php -e -v php -m
to reload and then list your modules. imagick should be listed, if not check your php.log for errors. If it is you can be sure that after an IISreset the module will be active for the running environment.
Now that the module is loaded we can use the following (just use the commandline which is open). This can be done with or without the iisreset:
php -i >phpinfo.txt
This will create a TXT-File with all the info of your PHP installation. Search for “imagick” and we get this piece of information
ImageMagick version => ImageMagick 6.8.6-8 2013-08-04 Q16 http://www.imagemagick.org
Now get the version of this setup corresponding to your php version (x86 or x64, this info is also included in the TXT). I found mine here.
Install this version like you would with any program. I left it at the standard settings and used a test.php like this one:
$im = new Imagick(); $im->newPseudoImage(100, 100, "magick:rose"); $im->setImageFormat("png"); $im->roundCorners(5,3); $type=$im->getFormat(); header("Content-type: $type"); echo $im->getimageblob();
After another IISreset I could use this snippet and retrieve a neat little picture of a rose.
Big thanks to Kris who gave me the basic idea on how the .dll should be set up. I just made this article to show a bigger picture of his comment.
Also a shoutout to the developer of Lychee Tobias Reich. Love your tool so far. I just hope you see the comment I put on your latest version (master) of photo.php which prevents (me) from uploading any pictures. Also, if I hadn’t brought Imagick to live the crunching wouldn’t work for medium-size pictures.