imagick and imagemagick Extension Tutorial for Installing php under windows7

  • 2021-07-06 10:40:09
  • OfStack

In the recent PHP project, the effect of cutting and thumbnails was needed, and the php imagick extension was easily installed on the linux test server. However, in the local windows development environment, the installation process encountered many problems, which I would like to share with you.

1. Download ImageMagick
Download address: http://imagemagick.org/script/binary-releases.php # windows

Download the latest version, ImageMagick-6. 8.6-9-Q16-x86-dll. exe

2. Install ImageMagick
Install ImageMagick on PC. The installation path cannot have spaces, otherwise it cannot be used. When installing, select Add Execution Path to path at 1 o'clock, otherwise you will have to add path path manually.

Step 3 Test the installation
Open the windows command line window (win+r- > "cmd"- > Enter), enter convert, enter. A help document for convert appears, which indicates that the installation was not successful, or that the installation directory was not added to the environment variable path.

Add to environment variables such as my ImageMagick installation directory is c:/imagemagick.

Add process:
My computer- > Right-click- > Advanced System Settings- > Advanced- > Environment variables- > System variables- > path - > Select and edit- > Add your installation directory to it

4. Download the php extension php_imagick. dll


php5.4. x or php5.5. x Download address http://www.peewit.fr/imagick/

dyn = dynamic, st = static, q16 = 16 bit, q8= 8 bit.

The above logo is the same as the ImageMagick download logo you downloaded. I use q16

5. Rename the dll file to php_imagick. dll and place it in the php Extended File Directory php/ext.

6. Add extension=php_imagick. dll in the php. ini configuration file.

7. Restart the computer. If it doesn't work to restart apache, restart PC. Because imageMagic software is used in the extension bottom layer, the software restarts the computer, reloads the software, and refreshes the path path.

8. After restarting, open the phpinfo page and check that the extension has been installed successfully. If the installation has not been successful, it is very likely that the imagemagick software version is too high. Please choose a lower version of 1 level to install.

9. PHP test code.


<?php
$im = new imagick( 'a.jpg' );
// resize by 200 width and keep the ratio
$im->thumbnailImage( 200, 0);
// write to disk
$im->writeImage( 'a_thumbnail.jpg' );

10. Check the manual and learn API

The related Extended Learning Manual address http://uk3.php.net/manual/zh/book.imagick.php contains a large number of easy-to-use examples.

There is also the document http://www. imagemagick. org/Usage/for viewing command line parameters


Related articles: