ImageMagick is installed correctly on XAMPP yet cannot read in a file for editing/conversion
Posted: 2015-12-02T00:39:01-07:00
My webserver has ImageMagick installed and available (and works correctly), and so I want to make use of it. To do that, I need to run it on my localhost, which is XAMPP, to test code, etc. I've succeeded in installing it on XAMPP, however it fails to be able to read a specified file for operation. Below I've listed precisely how I've set up ImageMagick on XAMPP and an description of the problem, which I hope can be reproduced by a reader and the solution found. It may simply be a set-up issue, or it may be a true bug within the version of ImageMagick I'm using.
I'm using the current version of XAMPP (Version 5.6.14) with Apache/2.4.17 (Win32) and PHP/5.6.16 on Windows 8.1
To install ImageMagick locally, I created this directory off the root:
c:\ImageMagick
Then, from here:
http://windows.php.net/downloads/pecl/deps/
...I downloaded the X86 thread-safe version that would match the DLL (which you have to obtain separately, which mystifies me). The version I downloaded was:
ImageMagick-6.9.1-2-vc11-x86.zip
I unzipped it to C:\ImageMagick and then moved the contents of its "bin" subfolder to C:\ImageMagick, so that everything is in the root of that directory.
I then added C:\ImageMagick to my PATH and verified that it worked by first exectuting from a command line at a different directory, which then caused the help screen info to display. I then further verified it worked by performing an image resizing from the command line successfully. So far so good.
Then, following the advice culled from other online postings about how to do this, I copied the CORE_RL_*.DLL files and the IM_MOD_RL*.DLL files from C:\ImageMagick to c:\xampp\apache\bin
I then added this system environment variable:
The next step is to add php_imagemagick.dll to the php\ext folder in XAMPP, but there's no such DLL among those in the ImageMagick ZIP files/EXEs. To get it, I had to go here:
http://windows.php.net/downloads/pecl/r ... /3.3.0rc2/
...and download:
php_imagick-3.3.0rc2-5.6-ts-vc11-x86.zip
...I then unzipped it to a dedicated "junk" directory and copied the php_imagemagick.dll file it contained to c:\xampp\php\ext
I then edited the php.ini file in c:\xampp\php to include this directive:
Now...the moment of truth:
I started XAMPP and checked the PHP_ERROR_LOG, and found no errors. I then ran PhpInfo.php and confirmed that ImageMagick was loaded; here is the screen shot:
So, that would seem to indicate that XAMPP recognizes ImageMagick, and that is has been installed correctly and with no errors.
Now for the meat of the issue: when the following script is run from my live server (DreamHost), it successfully converts the X.JPG image as indicated (notice the redundant check for the imagick extension at the beginning):
However, when I run this code from my XAMPP localhost, it gets as far as creating the $im (the ImageMagick object), but it does not proceed to read in the image with the readImage() function ("Created object..." is written to the screen, but nothing beyond that, and no output file is created).
Any suggestion as to what I may have omitted in my installation?
I'm using the current version of XAMPP (Version 5.6.14) with Apache/2.4.17 (Win32) and PHP/5.6.16 on Windows 8.1
To install ImageMagick locally, I created this directory off the root:
c:\ImageMagick
Then, from here:
http://windows.php.net/downloads/pecl/deps/
...I downloaded the X86 thread-safe version that would match the DLL (which you have to obtain separately, which mystifies me). The version I downloaded was:
ImageMagick-6.9.1-2-vc11-x86.zip
I unzipped it to C:\ImageMagick and then moved the contents of its "bin" subfolder to C:\ImageMagick, so that everything is in the root of that directory.
I then added C:\ImageMagick to my PATH and verified that it worked by first exectuting
Code: Select all
convert
Then, following the advice culled from other online postings about how to do this, I copied the CORE_RL_*.DLL files and the IM_MOD_RL*.DLL files from C:\ImageMagick to c:\xampp\apache\bin
I then added this system environment variable:
Code: Select all
MAGICK_HOME=c:\imagemagick
http://windows.php.net/downloads/pecl/r ... /3.3.0rc2/
...and download:
php_imagick-3.3.0rc2-5.6-ts-vc11-x86.zip
...I then unzipped it to a dedicated "junk" directory and copied the php_imagemagick.dll file it contained to c:\xampp\php\ext
I then edited the php.ini file in c:\xampp\php to include this directive:
Code: Select all
extension=php_imagemagick.dll
I started XAMPP and checked the PHP_ERROR_LOG, and found no errors. I then ran PhpInfo.php and confirmed that ImageMagick was loaded; here is the screen shot:
So, that would seem to indicate that XAMPP recognizes ImageMagick, and that is has been installed correctly and with no errors.
Now for the meat of the issue: when the following script is run from my live server (DreamHost), it successfully converts the X.JPG image as indicated (notice the redundant check for the imagick extension at the beginning):
Code: Select all
<?php
if (!extension_loaded('imagick')) {
echo "imagick not installed...";
} else {
echo "imagick installed...";
}
echo "Start...";
$uploaded_filename = "x.jpg";
$im = new Imagick();
echo "Created object...";
$im->readImage("x.jpg");
echo "Read JPG...";
$im->resizeImage(528, 0, Imagick::FILTER_LANCZOS2SHARP, 1);
$im->stripImage();
$im->writeImage("x_lg.jpg");
$im->clear();
$im->destroy();
echo "Done."
?>
Any suggestion as to what I may have omitted in my installation?