[Tutorial] How to install Imagick


  • administrators
    | 47916 points

    Installing Imagick 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.3RC1/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.0.10-Win32-VC14-x86 you should download:

    PECL:
    http://windows.php.net/downloads/pecl/releases/imagick/3.4.3RC1/php_imagick-3.4.3rc1-7.0-ts-vc14-x86.zip
    Imagick Binaries & Dlls:
    http://windows.php.net/downloads/pecl/deps/ImageMagick-6.9.3-7-vc14-x86.zip

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

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

    That's all forks.


  • administrators
    | 47916 points


  • administrators
    | 47916 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
    | 47916 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.


  • | 1274 points

    I am getting The program can't start because CORE_RL_wand_.dll is missing from your computer.

    It's already in C:\laragon\bin\php\php-7.0.12-Win32-VC14-x86 where my PHP is installed.

    I used your links since they should be using the same versions.


Log in to reply
 

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