Imagick php windows

后端 未结 7 538
甜味超标
甜味超标 2020-12-30 14:55

I am trying to use iMagick in Symfony2.

I am using PHP 5.4.16 and all i have done :

1-Copy php_imagick_nts.dll from php5-4 directory from the extracted http:

相关标签:
7条回答
  • 2020-12-30 15:33

    I spent many hours trying to make Imagick work, finally I got it.

    My installation instructions

    1. Install WAMP 32bit (even if you running 64bit system you must use 32bit version of WAMP)
    2. Install ImageMagick to C:/imagemagick, use this file: https://www.dropbox.com/s/i2mhrhd7sp0ilzk/ImageMagick-6.8.0-3-Q16-windows-dll.exe
    3. Put DLL with Imagick into extension folder of PHP, e.g. D:\wamp32\bin\php\php5.4.16\ext, I used this file: https://www.dropbox.com/s/ayankf850l08rm2/php_imagick.dll
    4. In php.ini put line "SetEnv MAGICK_HOME C:/imagemagick" without quotes
    5. Better restart PC

    I use Wamp 2.4, PHP 5.4.16, Apache 2.4.4, ImageMagick 6.8.0-3 2012-10-24 Q16, Imagick 3.1.0RC2 - all 32bit, OS Win8 64bit

    Now it should work and you should see Imagick extension loaded in phpinfo.

    I tried a lot of versions of ImageMagick, but newer versions didn't work, 6.8.0-3-Q16-windows-dll works fine.

    Symfony2

    In Symfony2 use Imagick like this:

    $im = new \Imagick('image.jpg');
    
    0 讨论(0)
  • 2020-12-30 15:39

    I'm quite sure this is to do with not having the module loaded correctly or the .dll being placed in a improper location.

    You can use PHP's internal function extension_loaded() to check prior to using the class,

    <?php
      /**
       * 
      **/
      if (!extension_loaded('Imagick')) {
            //Load some error.
      }
    ?>
    

    That's a method you can check if the module is even being reconsigned by PHP at all. PHP also provides a function to view your current extensions get_loaded_extensions():

    <?php 
       /**
        *   Get an Array of current
        *   PHP extensions for debugging
       **/
       print_r( get_loaded_extensions() );
    ?>
    

    Make sure you do:

    • Check your correct extension library folder location within your phpinfo()
    • Perform a hard restart of your xmapp/wamp server.
    • If you're on PHP 5.4 or upwards (Like yourself!), see site below for the updated binaries

    After researching too, Imagick does seem to have trouble with PHP 5.3 or upwards; Download new DLL's from this site below (Unofficial):

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

    Also found other StackOverFlow Articles that have the same problem:

    Stackoverflow: Trying to get imagick running on PHP 5.4.3 at Windows x64

    Alternatively you're able to use the GD extension to more or less accomplish some of the same functions you require. I do believe GD is a more widely supported module/extension in more recent versions of PHP.

    0 讨论(0)
  • 2020-12-30 15:40

    Sorry for my bad english:

    1º Install Appserv

    Filename: "appserv-win32-2.5.10.exe"

    URL download: h*ttp://www.appservnetwork.com/ (without *)

    Apache port: 8080

    2º Download PHP 5.3(Apache 2.2 doesn't support superior)

    Filename: "php-5.3.29-Win32-VC9-x86.zip"

    How?: Thread Safe

    URL Download: h*ttp://windows.php.net/download#php-5.6 (without *)

    3º Stop Apache

    4º Delete all contents in the folder "..\AppServ\php5"

    5º Copy the zip contents to "..\AppServ\php5"

    6º Add line

    date.timezone = "America/Buenos_Aires" (This is my zone, find yours in php page)

    to the "php.ini" in "c:\Windows\php.ini"

    to avoid date error in PHP

    7º Start Apache

    =============================

    IMAGIC(Once PHP 5.3 is installed)

    1º Instalññ Image magic 6.7(Not superior, PHP 5.3 doesn't support)

    Filename: "ImageMagick-6.7.9-9-Q16-windows-dll.exe"

    URL download: http://ftp.icm.edu.pl/packages/ImageMagick/binaries/

    2º Download Imagic

    Filename: "php_imagick-3.1.2-5.3-ts-vc9-x86.zip"

    URL download: http://windows.php.net/downloads/pecl/releases/imagick/3.1.2/

    3º In the dir "php5/ext" add the file "php_imagick.dll" from the last zip download(other files doesn't care)

    4º Add line

    extension=php_imagick.dll

    to the "php.ini" in "c:\Windows\php.ini"

    5º Restart Apache

    0 讨论(0)
  • 2020-12-30 15:43

    After trying many solutions, none seemed to work.

    I managed to install it on Windows 10 64-bit, Apache 2.4 and PHP 5.6, but I think it should work for all versions.

    Hopefully you will have no problem installing Imagick for PHP.


    Step 1) Gather information

    First of all you should gather some information of your PHP environment.

    You can easily see your PHP information with the function phpinfo()

    The information you need:

    • Architecture: x86(32-bit) or x64(64-bit)
    • PHP-version: you can find this in the header of the phpinfo() output.
    • PHP Extension Build: This string contains 2 important parts:
      • NTS or TS
      • VCx (like VC11)
    • Loaded Configuration File: the path to your used php.ini file.

    Step 2) Download Binary

    You can download the binary from the official site of ImageMagick. I recommend you to read the small introduction under the "Windows Binary Release" to be certain which "bits-per-pixel" to choose from(8 or 16). Downloading the latest version should be just fine.

    Make sure this binary is the same architecture as your PHP architecture that you have gathered in step 1.

    Step 3) Install Binary

    Install the binary to your phpx.x.xx\bin file. For example: C:\wamp64\bin\php\php5.6.16\bin. (This can be any folder, but for the convenience I put in here)

    Make sure "Add application directory to your system path" is checked. Should be checked by default though.

    Step 4) Download PHP extension

    The DLL PHP extension is available through the windows pecl php site

    Again, you can just click the latest version.

    Next of, choose the right version based on the gathered information.
    For example: php_imagick-3.4.1-5.6-nts-vc11-x64.zip

    This can be stripped into components:

    • php_imagick-3.4.1 - This is the php imagick extension with the version. This is not important.
    • 5.6 - This is your PHP version and should be equal to the PHP-version you are using, which you have determed in step 1.
    • NTS - This should be equal to the information of your PHP Extension Build that you have gathered in step 1.
    • VC11 - This should also be equal to the information of your PHP Extension Build that you have gathered in step 1.
    • x64 - This the architecture of the extension and should be equal to your PHP architecture that you have gathered in step 1.

    Step 5) Extract PHP Extension

    After you have downloaded the file, you should open the .zip file and look for a file named: php_imagick.dll. Extract this file to phpx.x.xx\ext.

    Make sure the .dll file is fully accessable by you. Sometimes you need to explicity unblock the file.

    Step 6) Activate PHP extension

    To activate the extension in PHP, you should state in your php.ini file that you want to use this extension. You have gathered the path to your used php.ini file in step 1.

    Add the line extension=php_imagick.dll to your php.ini

    Step 7) Restart your PC

    Just to make sure, restart your PC so all Environment Paths will be correctly loaded.


    This should install Imagick correctly with the latest versions and the right architecture. Imagick should also be listed in phpinfo() with the appropriate "ImageMagick supported formats" (Just make sure it is not empty).

    0 讨论(0)
  • 2020-12-30 15:48

    I use :Wamp 2.4, PHP 5.4.16, Apache 2.4.4, ImageMagick 6.8.0-3 2012-10-24 Q16, Imagick 3.1.0RC2 - all 32bit, OS Win7 32bit

    Instructions given by fmstoun worked for me perfectly. Since I spent a lot of hours trying to make the dll work, I wanted to add on to steps given by fmstoun.

    • Do restart your PC.
    • Use the full path to the image, for example:
    $image = new Imagick($_SERVER['DOCUMENT_ROOT'] . '/images/test.jpg');
    • Make sure your system environment has 1 single entry for : C:/imagemagick and no more environment variables for imagemagick. If any previous installations have the path, then remove those paths and restart your PC
    • Make sure
      http : / / localhost/
      of wamp shows 'imagick' as loaded extension
    • If extension is loaded properly, it has to show up in phpinfo() also as:
    • imagick module  | enabled
    • ImageMagick version|ImageMagick 6.8.0-3 2012-10-24 Q16 
      and some more information about imagemagick.

    Considering the date of this post, the latest version of imagemagick provided on the official site is: ImageMagick-6.8.8-1-Q16-x86-dll.exe which fails to load the extension (as seen in apache error logs after a restart). Hence use the version mentioned by fmstoun.

    Hope this answer saves couple of hours of effort and saves time required to go through around 15 SO questions on same topic and also different forums.

    0 讨论(0)
  • 2020-12-30 15:48

    UPDATE for those 2019 also using WAMP, a much more simplier method of ImageMagick are as follows:

    1. Go to https://mlocati.github.io/articles/php-windows-imagick.html.
    2. Grab a copy of the .dll extension file of your appropriate setup, choose a "Threads Safe" version.
    3. Grab the corresponding ImageMagick using the link on the same row and install it.
    4. Copy only the .dll file to the extensions folder of your install of WAMP, usually C:\wamp\bin\apache2.4\ext\
    5. Restart apache.

    Hope this helps.

    0 讨论(0)
提交回复
热议问题