Skip to content
Advertisement

Cannot make Imagick detect supported format on Windows + PHP 5.6 (Xampp)

its been 3 days of research, google and frustration to make imagick work on my XAMPP box. I can get as far on making it as php module. But it cannot detect supported formats. enter image description here

As you can see, I currently have 3.1.2 installed, but I actually worked all the way from the most recent 3.4.1 and jumping from those releases tagged with stable but I just can’t make it work.

When I try to run:

<?php
$handle = fopen('http://xxxxx.png', 'rb');
$img = new Imagick();
$img->readImageFile($handle);
$img->thumbnailImage(100, 0);
echo $image;

I am getting:

Uncaught exception 'ImagickException' with message 'Unable to read image from the filehandle' in xxxxx:5 Stack trace: #0 xxxxxindex.php(5): Imagick->readimagefile(Resource id #3) #1 {main} thrown in xxxxxindex.php on line 5

What I have is:

Windows 8.1 64-bit
PHP 5.6.12, x86, TS

(http://i.imgur.com/2pnneqO.png)

This is what I actually have done so far, in terms of installing it:

  • Download any -Thread Safe (TS) x86 package from https://pecl.php.net/package/imagick
  • Extract the .zip (1) php_imagick.dll to C:_XAMPPphpext (2) Extract CORE_RL_* files to C:_xamppapachebin
  • Download ImageMagick-7.0.1-1-Q16-x86-dll.exe from Link
  • Installed it at C:ImageMagick
  • Add MAGICK_HOME to environment PATH. http://i.imgur.com/jQAWl3W.png
  • All *_.dll file in C:ImageMagickmodulescoders copy to C:_Xamppapachebin
  • All *_.dll file in C:ImageMagickmodulescoders copy to C:ImageMagick
  • Restart Apache via Xampp

And still can’t make my PHP detect Imagick supported file formats even though they should be http://prntscr.com/b1l54u :((

Can somebody tell me what did I miss? Please?

Advertisement

Answer

You seem to be going a bit of a convoluted route.

The method I used to install it when I had it running was:

  1. Download and install Ghostscript with an exe file
  2. Download and install imagemagick with an exe file – make sure you let it add the path to the environmental variables. You may not need this step but I wanted to use Imagemagick I’m my website and on my computer anyway.
  3. Download the Imagick dll file and put it in the recommended folder – I can not remember which now.
  4. Uncomment the Imagick option in the php.ini file. I had two or three php.ini files on my system and I did it in each one.
  5. Turned off the computer and restarted. Started XAMPP and it worked.

This only worked for a couple of installs and when I upgraded the operating system I could not get it to work due to incompatible versions of php and the Imagick.dll. If I should ever want to use Imagick I would do it on my server as the hosts installed it there for me. You can still write your code locally and test it on your production server. It is a bit of a pain but would probably be quicker/easier than trying to get Imagick working on your PC.

Out of interest I gave up with it and use Imagemagick with exec() and the command line.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement