14

I have installed the imagick from here (ImageMagick-7.0.3-1-Q16-x64-dll) and the dll (TS 32 bit) from here. And also copiend the CORE_RL_* to the C:\xampp\apache\bin BUT still i get the following error when i run the laravel server.

ERROR: Warning: PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_imagick.dll' - The specified module could not be found. in Unknown on line 0

Also, I placed dll file in C:\xampp\php\ext\php_imagick.dll.

Also, the imagick is shown in the phpinfo(). enter image description here

And when i use it using laravel i get the following error. enter image description here

Glorfindel
  • 20,880
  • 13
  • 75
  • 99
Jamal Abdul Nasir
  • 2,417
  • 5
  • 26
  • 47

2 Answers2

30

getting Imagick to work on Windows has always been a bit hit and miss as pointed out here is a good guide http://stackoverflow.com/a/36378764/1090867

But it misses an important point

You do not need to put the binary into the PHP folder!

So here are the steps I follow myself every time I need to do this. This should work for apache, Nginx, or IIS.

Step 1

find out your php version and setting

enter image description here

You need to version, Architecture, Compiler and Thread Safety

if Thread Safety is disabled this is NTS is enabled it will TS

Step 2

Get and install a copy of ImageMagick and make sure it matches your Architecture, this also needs to be dll.exe rather than the static version.

Regarding Q8 and Q16 I'll leave that to you but both versions will work

Link

I recommend changing the install directory name to something generic like C:\Imagemagick since I've had some problems in the past with the default directory name with PHP and windows.

Just install but make sure you tick add application path and I normally tick the legacy utils as well.

enter image description here

Once it's installed go to your environment variables and make sure it is actually in the path. There is no need to copy anything to your PHP folder

Just to make sure everything is working open the command line and type convert --version you should get a response

Step 3

This unfortunately is the hard part and can be a bit of trial and error. I've found the following provides the best php_imagick.dll that seems to work 9 times out of 10

http://www.peewit.fr/imagick/

Just pick the version that matches your install.

If this doesn't work then go to php.net and try each version until one works... (start at the latest)

http://windows.php.net/downloads/pecl/releases/imagick/

Once you have a php_imagick.dll put it into your php/ext/ folder

thne locate your php.ini file go to the bottom (or whereever your extensions are) and add extension=php_imagick.dll

Step 4

Restart PHP (or your computer) and it should be working if not try a different php_imagick.dll and repeat.

If the above doesn't work

Then try a slightly older version of Imagick I normally use version 6.8.6-8 Q16.

Please note I've only ever really done this on Windows 7 and Windows Server 2008, 2008 R2, 2012, and 2012 R2 all x64 with x86 PHP

If this still doesn't work then you probably need to copy over the CORE_RL files into your Imagick directory this normally causes more issues but if you are running out ideas then give it a go

Adelin
  • 16,512
  • 24
  • 100
  • 152
Avenyet
  • 410
  • 4
  • 7
  • 3
    Your very last sentence did the trick for me ... Copy the CORE_RL files from the archive with the php_imagick.dll directly into the imgagick install folder. It wasn't necessary to overwrite existing DLLs however, only add the ones that were missing. – rwired Jun 09 '17 at 16:52
  • 1
    O|O: Enhanced tutorial: http://ourcodeworld.com/articles/read/349/how-to-install-and-enable-the-imagick-extension-in-xampp-for-windows. Tested in: XAMPP Version 7.1.1, Php 7.1.1, Windows 10 Pro, ImageMagick 6.9.3-7-vc14-x86.zip – Felix Aballi Jul 18 '17 at 18:11
  • Yup, same here for the last sentence! – chocochaos May 17 '18 at 09:35
  • This needs more visibility. THANKS. – LuBre Mar 26 '19 at 19:35
24

I just ran into this issue. Only I'm using PHP on the command line (PHP CLI). The problem is the dependencies that the main php_imagick.dll file has. PHP will attempt to load the extension but since Windows can't find the CORE_RL_ DLLs, the extension will fail to load and the error/warning message about being unable to load the DLL will appear. It helps to know how Windows loads DLLs:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms682586(v=vs.85).aspx

It's pretty convoluted but you can see that the reason the Apache /bin directory trick works with Apache is that httpd.exe is located in that directory. However, when using PHP CLI, the DLLs need to be located in the same directory as php.exe.

If you don't want duplicate DLLs floating around, add the directory containing php.exe to the system PATH and plop all the CORE_RL_ DLLs there. The PATH is the last thing searched, but it'll work fine. If you don't want spurious entries in your system PATH, then set the extra PATH information only during startup of Apache.

CubicleSoft
  • 1,985
  • 18
  • 19
  • 2
    thanks, I found this answer is more straight forward. WinNMP requires ALL the .dll and .pdb inside the folder containing php.exe for imagick to work. Then put the php_imagick.dll inside /ext. Always check the php log, they will give you the clue. – AzDesign Sep 27 '19 at 07:35
  • Place the imagick .dlls into the php folder containing php.exe. You, my friend, deserve a medal. – cliffclof Feb 20 '22 at 11:39
  • Thanks. I maintain a large number of repos over on GitHub - mostly PHP and C++ projects. A star or fork isn't exactly a medal but feel free to peruse the list of repos and star/fork away at projects of any interest: https://github.com/cubiclesoft/ – CubicleSoft Feb 23 '22 at 00:38