[Tutorial] How to install ImageMagick


  • administrators
    | 105364 points

    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):

    1. 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.zip

    After downloading the right packages, the next steps are easy.

    1. 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)
    1. Enable:
      Just click Menu > PHP > Extensions > imagick

    2. Restart Apache/Nginx

    That's all forks.


  • administrators
    | 105364 points


  • administrators
    | 105364 points

    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:
    0_1484388356126_imagick-php.png


  • | 137 points

    @leokhoa

    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


  • administrators
    | 105364 points

    @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.


  • | 2476 points

    @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.dll

    Step 3 php should I copy the folder or folder ext?


  • administrators
    | 105364 points

    @sajjadkazemi10 : I copied to PHP dir (no ext) and it worked. So, try it.


  • | 2476 points

    @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 message

    warning: 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


  • administrators
    | 105364 points

    @sajjadkazemi10: Please provide me:

    1. A picture of your PHP dir
    2. 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

  • | 2476 points

    @leokhoa
    The message appears only

    warning: 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


  • administrators
    | 105364 points

    @sajjadkazemi10 : pls answer my questions properly


  • | 2476 points

    This post is deleted!

  • | 2476 points

    @leokhoa I email the photos to you


  • administrators
    | 105364 points

    @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.zip

    I guess you download a wrong package.


  • | 2476 points

    This post is deleted!

  • | 2476 points

    @leokhoa I downloaded the package


  • | 2476 points

    @leokhoa Through software TeamViewer 12 look?


  • | 2476 points

    @leokhoa

    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


  • | 604 points

    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?


  • | 697 points

    @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.


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.