Imagick window & biến môi trường
Learn how to configure the Imagick extension in XAMPP for Windows. Show Imagick is a native PHP extension to create and modify images using the ImageMagick API. The name causes some confusion as people think that ImageMagick and Imagick are the same thing, however they aren't. You can use ImageMagick without Imagick but you need both Imagick and ImageMagick installed to run it within your PHP code. You can check with PHP code wheter the Imagick extension is installed or not using:
Or just errors in your code that implements Imagick will tell you ... : Attempted to load class "Imagick" from the global namespace. Did you forget a "use" statement? Class 'Imagick' not found In XAMPP for Windows, Imagick isn't built-in, therefore is up to you its installation and implementation. If you have already searched previously how to install Imagick in XAMPP to make it work, and you just can't do it, you're probably out of bounds and you want to kill yourself. Fortunately, in this article you'll find the definitive installation of Imagick for XAMPP in Windows. Pre-installation notesWe need to mention that the installation of Imagick is not easy (can be a little confusing) and you may get errors during the installation if you don't follow carefully every step by step. Besides, you need to know the following information about your PHP distribution: Note: according to the version of XAMPP that you use, these values can vary.
You can get those values with the
Once you know the values, these will instruct with files with which architecture you need to download from all the following steps. Note: don't forget neither to execute every setup with administrator rights. 1. Download and install ImageMagick for WindowsNavigate in your browser to the
Downloads area of the website of Imagick and scroll to the Windows zone. ImageMagick runs in almost every version for Windows (from Windows server 2009, XP to Windows 10), now from this list is important to download the latest available version with Download the executable and wait. Till the moment, we don't need to configure anything for PHP, just proceed with the installation of Imagick for Windows and don't forget to check the option to add Imagick to the PATH: Once the setup finishes, you can test Imagick in a new command prompt executing (that should print the version in the console):
2. Download Imagick for PHPNow navigate to the Imagick package in the PECL website here and select the DLL version from the latest available version (in case you've downloaded an older version of ImageMagick then download a version that accepts your version): Then a new window will load, in this page scroll to DLL List and click on the right version for your PHP version with correct architecture (of XAMPP not your operative system) and the Thread Safe in case that it's enabled in your distribution (Refer to phpinfo to know wheter your php distribution uses Thread Safe or not): This
will start the download of a zip file " Then, proceed to enable the extension in your
Now the extension is loaded, but Imagick still won't work as it won't even be recognized as an extension if you check the phpinfo file because we need to load all the methods and the binaries that you can retrieve from the next step. 3. Download required Imagick binariesAt this point you may be asking to yourself, really dude ? 3 different downloads? The problem with Imagick is that there are a lot of builds from different sources and if you don't download and install the right ones, it wont work or it will be loaded but if you check the Imagick extension (later, not yet) in phpinfo you'll see :
That's why you need to follow the steps as mentioned, otherwise you won't make Imagick to work. To prevent any implementation error, the binaries needs to come from the same source, in this case Download the version that matches with the architecture of xampp and check the compiler version. In
this case, we download the third option with a filesize of about 30MB ( Once the content of the file is extracted, open the Now start the apache service (or restart it in case it's already running) and go to And you can finally after hours of suffering, use Imagick with PHP for XAMPP in Windows. In case of console errorIf after the implementation you still getting the following message error everytime you use PHP (at least in the console): PHP Warning: PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_imagick.dll' - The specified module could not be found. You will need to add the Happy coding ! How do I run ImageMagick on Windows?You have 2 choices. 1) Use the full path every time you run ImageMagick, i.e. something like "C:\Programs\Image Magick\convert" or 2) Go to Settings -> System -> Advanced -> Environment Variables and click Edit and add the directory in to the start of your PATH.
How do I install Imagick on Windows server?Download the latest imagick pecl package that matches the 'Thread Safety' of your php install from https://windows.php.net/downloads/pecl/releases/imagick/. Find 'Thread Safety' in your phpinfo output. Avoid the release candidate packages, those with 'rc#' in their name. For reference, php_imagick-3.4.
How do I install Imagick?Install ImageMagick extension: Now install the ImageMagick PHP extension by using the following command. Install Imagick extension: After completion of ImageMagick package, the Imagick PHP extension will install. Restart Apache Server: Restart the apache server by using the following command.
How do I enable Imagick?To enable Imagick for your website, go to your Site Tools -> Dev -> PHP Manager. Click the PHP Extensions tab and find the entry for the “imagick” extension in the list that appears. Then click the Change value button (pencil icon), select the On radio button for Status and save the changes.
|