Home » Php » php – How to install imagick in xampp/wampp in Windows

php – How to install imagick in xampp/wampp in Windows

Posted by: admin April 23, 2020 Leave a comment

Questions:

Today I have tried to install imagick in my xampp a hundred of times. And I did it. If you have troubles, please try following this steps:

  1. Since xampp is x86, check if your Image Magick (the program) is x86. If not, download the lastest version here: imagemagick.org/script/binary-releases.php#windows
    Please remember that u MUST download the Win32 dynamic at 16 bits-per-pixel.
  2. Install Image Magick at C:\imagemagick.
  3. Download the lastest stable version of imagick here: . You MUST download the 5.x Thread Safe (TS) x86. The x in 5.x is the version of your PHP.
  4. Put the php_imagick.dll in php/ext folder of your xampp installation.
  5. Add this in your php.ini: extension=php_imagick.dll
  6. Here is when i have a lot of troubles. If you try to start the server (or writing php in the console (start->cmd)), you will get an error. If that error says something like this: Unable to find the entry point for the procedure FlattenImages in the DLL CORE_RL_magick.dll it means that you’re well under way.
  7. Now, you must go into the installation folder of Image Magick and overwrite the DLL you downloaded with the php_imagick.dll. All of they start with the prefix CORE_RL_.
  8. Once you overwrited all of them, you can try writing php in the windows console. If dont say something means that the imagick is functionally (you can check in localhost/xampp/ > phpinfo() link. Personally i had to install a new DLL: vcomp110.dll.
    If someone have the same error than me (the system can’t found the vcomp11.dd) download it here

Now, if you try excuting php on console, or just initializing the apache module of xampp, you should not have errors.

Good bye and hope I can help someone.

EDIT: when tried to convert some-img.bmp some-result.jpg in the console, i had this error:
convert.exe: unable to open module file 'C:\Users\my-acc\.magick\IM_MOD_RL_BMP_.dll': No such file or directory @ ...
This happend when there are no folder .magick in my-acc. The thing you need to do is this:

  1. Create a folder named .magick in the my-acc folder. Since the name starts with a stop, you need to create it through the console. Here are the commands:

    1.1. c:

    1.2. cd Users\my-acc

    1.3. mkdir .magick

  2. Go to C:\imagemagick\modules\coders and copy the entire files into the lastest folder created.

Now, you will be able to use Image Magick through the commands or the PHP Classes.

On background, if you use Codeigniter, i have no idea how to use the image_lib with imagick. So, it’s better with the own imagick classes. Here a simple example:

$image = new Imagick($upload_data['full_path']);
$image->thumbnailImage(250,0);
if($image->writeImage($upload_data['file_path'].$upload_data['raw_name'].'_thumb'.$upload_data['file_ext'])){
    something here;
}
$image->clear();
How to&Answers:

This answer might be extremely naive, but, I’ve found that getting things done in Windows is generally too painful. Many people agree with that and have found solace in a tool known as “chocolatey”.

First, install chocolatey on your Windows machine (super easy install instructions):

https://chocolatey.org/

Then, use chocolatey to install everything else that you need (imagemagick in this case):

https://chocolatey.org/packages/imagemagick

I suspect you might have to do some minor tweaking to configuration files after that, plus handle all of the “Windows permissions” needed to get things to work smoothly. Permissions are can be as simple (and not necessarily safe) as “full control” to some user, plus activating inheritance and overwriting all children’s settings to use inheritance.

In short, install, configure, permissions, go.

PS. This answer might be incomplete/prototypical/experimental, since I don’t run codeigniter, php, imagemagick on Windows.

Answer:

This how-to of Winderfind is wonderful, but for me it was not yet complete to troubleshoot all problems. First of all, have a look at this tutorial:
http://hrt0kmt.hatenablog.com/entry/2015/05/27/170608

Secondly I discovered that not all versions of ImageMagick will work with all versions of php_imagick.dll. Check out my and others answers on this post for further troubleshooting:
ImageMagick supported formats no value