[Tutorial] How to install ImageMagick
-
Installing ImageMagick is really pain on other systems. However, it is trivial with Laragon if you follow these below steps (works with both Apache & Nginx):
Video:- Download links:
PHP Extension (PECL):
https://pecl.php.net/package/imagick/3.4.3/windows
Imagick Binaries & Dlls:
http://windows.php.net/downloads/pecl/deps
*IMPORTANT: Choose the right packages (version, x86 or x64, VC, Thread Safe (ts) or Non Thread Safe (nts)).
Even your OS is 64-bit, you should depend on the suffix -x86 or -x64 of the PHP version to select the correct ones.To be more specific: if you are using php-
7.1
.7-Win32-VC14
-x64
you should download:*
PECL:
http://windows.php.net/downloads/pecl/releases/imagick/3.4.3/php_imagick-3.4.3-7.1-ts-vc14-x64.zip
ImageMagick Binaries & Dlls:
http://windows.php.net/downloads/pecl/deps/ImageMagick-6.9.3-7-vc14-x64.zipAfter downloading the right packages, the next steps are easy.
- Extract:
- PECL: Extract php_imagick-3.4.3-7.1-ts-vc14-x64.zip to a tmp dir, then put just
php_imagick.dll
to PHP Extension dir (Menu > PHP > dir:ext) - Imagick Binaries & Dlls: Extract ImageMagick-6.9.3-7-vc14-x64.zip to a tmp dir, then put all dlls in bin (
CORE_RL_*.dll, FILTER_analyze_.dll, IM_MOD_RL_*.dll, ImageMagickObject.dll
) to PHP dir where the php7ts.dll is located (Menu > PHP > Version > dir:php-7.1.7-Win32-VC14-x64)
-
Enable:
Just click Menu > PHP > Extensions > imagick -
Restart Apache/Nginx
That's all forks.
- Download links:
-
Some pics:
http://localhost/?q=info
-
Test: Creating a PHP Logo
Ref: http://php.net/manual/en/imagick.examples-1.php
imagick.php<?php /* Set width and height in proportion of genuine PHP logo */ $width = 400; $height = 210; /* Create an Imagick object with transparent canvas */ $img = new Imagick(); $img->newImage($width, $height, new ImagickPixel('transparent')); /* New ImagickDraw instance for ellipse draw */ $draw = new ImagickDraw(); /* Set purple fill color for ellipse */ $draw->setFillColor('#777bb4'); /* Set ellipse dimensions */ $draw->ellipse($width / 2, $height / 2, $width / 2, $height / 2, 0, 360); /* Draw ellipse onto the canvas */ $img->drawImage($draw); /* Reset fill color from purple to black for text (note: we are reusing ImagickDraw object) */ $draw->setFillColor('black'); /* Set stroke border to white color */ $draw->setStrokeColor('white'); /* Set stroke border thickness */ $draw->setStrokeWidth(2); /* Set font kerning (negative value means that letters are closer to each other) */ $draw->setTextKerning(-8); /* Set font and font size used in PHP logo */ #$draw->setFont('Handel Gothic.ttf'); $draw->setFontSize(150); /* Center text horizontally and vertically */ $draw->setGravity(Imagick::GRAVITY_CENTER); /* Add center "php" with Y offset of -10 to canvas (inside ellipse) */ $img->annotateImage($draw, 0, -10, 0, 'php'); $img->setImageFormat('png'); /* Set appropriate header for PNG and output the image */ header('Content-Type: image/png'); echo $img;
Result:
-
Thanks for the tutorial. I have it up and running, but I can't seen to access it via the command line. I did a little research and it seems that the solution may be to set the $PATH for imagemagick.
Any idea how to do that?
Thanks,
Moshe
-
@MoreThinking: Instead of extracting ImageMagick-6.9.3-7-vc14-x86.zip to a tmp dir, you can extract to laragon\usr\bin and add it to PATH.
-
@leokhoa said in [Tutorial] How to install Imagick:
After downloading the right packages, the next steps are easy.
Extract:
PECL: Extract php_imagick-3.4.3rc1-7.0-ts-vc14-x86.zip to a tmp dir, then put just php_imagick.dll to PHP Extension dir (Menu > PHP > dir:ext)
Imagick Binaries & Dlls: Extract ImageMagick-6.9.3-7-vc14-x86.zip to a tmp dir, then put all dlls in bin (CORE_RL_.dll, FILTER_analyze_.dll, IM_MOD_RL_.dll, ImageMagickObject.dll) to PHP dir (Menu > PHP > Version > dir:php-xxx-xxx)Enable:
Just click Menu > PHP > Extensions > php_imagick.dllStep 3 php should I copy the folder or folder ext?
-
@sajjadkazemi10 : I copied to PHP dir (no ext) and it worked. So, try it.
-
@leokhoa
I used my laragon 2.2.2 full
I did the same thing
But the following error shows
Rather than point the following message dll files to the list with the same messagewarning: php startup: unable to load dynamic library 'c:/laragon/bin/php/php-7.1.5-nts-win32-vc14-x86/ext........ - the specified module colud not br found. i unknown on line 0
php7ts.dll
core_rl_magick.dll
core_rl_ttf.dll
core_rl_wand.dll
core_rl_zlib.dll
core_rl_lqr.dll
core_rl_lcms.dll
core_rl_glib.dll
core_rl_bzlib.dll
warnig : php startup: imgick: unable to initalize module
module complid with module api=20151012
php complid with module api=20160303
these options need to match
in known on line 0
warinig: php startup: unable to load dynamic library 'c:/laragon/bin/php/php-7.1.5-nts-win32-vc14-x86/ext\phar.so' - the specified module colud not br found. i unknown on line 0
-
@sajjadkazemi10: Please provide me:
- A picture of your PHP dir
- Which Imagick package did you download?
If you use PHP-7.1.5 nts x86, the package should be:
http://windows.php.net/downloads/pecl/releases/imagick/3.4.3RC1/php_imagick-3.4.3rc1-7.1-nts-vc14-x86.zip
-
@leokhoa
The message appears onlywarning: php startup: unable to load dynamic library 'c:/laragon/bin/php/php-7.1.5-nts-win32-vc14-x86/ext\php7ts.dll - the specified module colud not br found. i unknown on line 0
warinig: php startup: unable to load dynamic library 'c:/laragon/bin/php/php-7.1.5-nts-win32-vc14-x86/ext\phar.so' - the specified module colud not br found. i unknown on line 0
-
@sajjadkazemi10 : pls answer my questions properly
-
This post is deleted!
-
@leokhoa I email the photos to you
-
@sajjadkazemi10 : You still don't answer this:
Which Imagick package did you download?
If you use PHP-7.1.5 nts x86, the package should be:
http://windows.php.net/downloads/pecl/releases/imagick/3.4.3RC1/php_imagick-3.4.3rc1-7.1-nts-vc14-x86.zipI guess you download a wrong package.
-
This post is deleted!
-
@leokhoa I downloaded the package
-
@leokhoa Through software TeamViewer 12 look?
-
File php7ts.dll inside the folder php now only message I got was shown
warinig: php startup: unable to load dynamic library 'c:/laragon/bin/php/php-7.1.5-nts-win32-vc14-x86/ext\phar.so' - the specified module colud not br found. i unknown on line 0
-
Can you explain this part a little bit more?
"Imagick Binaries & Dlls: Extract ImageMagick-6.9.3-7-vc14-x86.zip to a tmp dir, then put all dlls in bin (CORE_RL_.dll, FILTER_analyze_.dll, IM_MOD_RL_.dll, ImageMagickObject.dll) to PHP dir (Menu > PHP > Version > dir:php-xxx-xxx)"Mostly the folder location.
Would it be something like C:/laragon/bin/php/php-7.1.1-Win32-VC14-x86/ here or there is another folder?
-
@leokhoa said in [Tutorial] How to install Imagick:
Imagick Binaries & Dlls: Extract ImageMagick-6.9.3-7-vc14-x86.zip to a tmp dir, then put all dlls in bin (CORE_RL_.dll, FILTER_analyze_.dll, IM_MOD_RL_.dll, ImageMagickObject.dll) to PHP dir (Menu > PHP > Version > dir:php-xxx-xxx)
Did this line means that I have to put all dlls in directory: C:/laragon/bin/php/php-5.6.16/bin (my PHP directory + bin directory)? Cause, if it's true, it's not working. Imagick extension was loaded but no number of supported formats.
Edit: I found the solution for my problem. Because I already installed imagemagick software before, my MAGICK_HOME set to c:\ImageMagick\modules\coders. All I have to do was to copy all IM_MOD_*.dll files to this directory. And my PHP imagemagick installation is working fine.