apt install php-imagick
or something along these lines).php_imagick
up and running on Azure App Service with Windows web workersDISCLAIMER:
If this totally and permanently bricks your site, don't blame me.
At this point we strongly encourage looking at Web Apps for Containers for ImageMagick based workloads. If for one reason or another you can't use that, read on.
Find suitable PHP extension and ImageMagick library dll's from
https://mlocati.github.io/articles/php-windows-imagick.html
Tested working:
PECL module: php_imagick-3.4.4-7.4-nts-vc15-x64.zip
- http://windows.php.net/downloads/pecl/releases/imagick/3.4.4/php_imagick-3.4.4-7.4-nts-vc15-x64.zip
ImageMagick Binaries: ImageMagick-7.0.7-11-vc15-x64.zip
- http://windows.php.net/downloads/pecl/deps/ImageMagick-7.0.7-11-vc15-x64.zip
Follow the PHP 7.0 guide, just match the right binaries.
Tested working:
PECL module: php_imagick-3.4.3-7.2-nts-vc15-x64.zip
- http://windows.php.net/downloads/pecl/snaps/imagick/3.4.3/
ImageMagick Binaries: ImageMagick-7.0.7-11-vc15-x64.zip
- http://windows.php.net/downloads/pecl/deps/
Follow the PHP 7.0 guide, just match the right binaries.
Get the latest stable php_imagick.dll from here - https://pecl.php.net/package/imagick (3.4.3-stable used in this guide).
Copy all CORE_RL_*
files to d:\home\site\ImageMagick\
Copy php_imagick.dll
to d:\home\site\ext\
Copy applicationHost.xdt
(it's in this repo under /site
) to d:\home\site
. That's the XML transform responsible for adding d:\home\site\ImageMagick
to PATH. Edit if you're using your own custom paths.
Add MAGICK_CODER_MODULE_PATH
Application Setting:
Name: MAGICK_CODER_MODULE_PATH
Value: d:\home\site\ImageMagick
Add MAGICK_HOME
Application Setting:
Name: MAGICK_HOME
Value: d:\home\site\ImageMagick
Add PHP_EXTENSIONS
Application Setting (apparently PHP 7.0 ignores PHP_INI_SCAN_DIR for some reason):
Name: PHP_EXTENSIONS
Value: d:\home\site\ext\php_imagick.dll
This is what you should have now:
Restart the Web App
At this point phpinfo()
should return a imagick
module section. Get the ImageMagick version that php_imagick.dll
was built against:
We take a dependency here on ImageMagick-6.9.3-7-Q16-x86-dll.exe. Download and extract (always get the one ending in -x86-dll.exe) - http://ftp.icm.edu.pl/packages/ImageMagick/binaries/ImageMagick-6.9.3-7-Q16-x86-dll.exe (i'm using extract loosely here because you actually have to INSTALL that InstallShield package on your machine to get to the DLLs. InstallShield has no in-place extract. Small price to pay though.)
Copy the IM_MOD*
and FILTER*
DLLs from modules\
to d:\home\site\ImageMagick
(don't copy the folder structure, just the DLLs, you should have a flat structure in d:\home\site\ImageMagick\
with just a bunch of DLLs).
It should now work, test with this snippet:
<?php
/* Create a new imagick object */
$im = new Imagick();
/* Create new image. This will be used as fill pattern */
$im->newPseudoImage(200, 200, "plasma:fractal");
/* Create imagickdraw object */
$draw = new ImagickDraw();
/* Start a new pattern called "gradient" */
$draw->pushPattern('gradient', 0, 0, 200, 200);
/* Composite the gradient on the pattern */
$draw->composite(Imagick::COMPOSITE_OVER, 0, 0, 200, 200, $im);
/* Close the pattern */
$draw->popPattern();
/* Use the pattern called "gradient" as the fill */
$draw->setFillPatternURL('#gradient');
/* Set font size */
$draw->setFontSize(36);
/* Annotate some text */
$draw->annotation(20, 50, "What do you mean this works and we still have daylight left???!!?");
/* Create a new canvas object and a white image */
$canvas = new Imagick();
$canvas->newImage(1200, 70, "black");
/* Draw the ImagickDraw on to the canvas */
$canvas->drawImage($draw);
/* 1px black border around the image */
$canvas->borderImage('black', 1, 1);
/* Set the format to PNG */
$canvas->setImageFormat('png');
/* Output the image */
header("Content-Type: image/png");
echo $canvas;
?>
NOTE: phpinfo()
should now report a bunch of formats being supported:
Follow the PHP 7.0 guide, just match the right binaries.
Tested working:
PECL module: php_imagick-3.3.0rc2-5.6-nts-vc11-x86.zip
- http://windows.php.net/downloads/pecl/releases/imagick/3.3.0rc2/
ImageMagick Binaries: ImageMagick-6.8.8-1-Q16-x86-dll.exe
- http://ftp.icm.edu.pl/packages/ImageMagick/binaries/