I need to use imagick
PHP extension for image manipulation. Before I installed this extension, I also installed ImageMagick on the machine using sudo apt install imagemagick
. Turns out, this version is outdated (because it’s not supporting HEIC image format). So I installed ImageMagick from the source, which installed as magick
package. But the PHP’s imagick extension is still working with earlier outdated imagemagick
.
How do I tell PHP’s imagick extension to use the latest magick
package I installed from source?
2
Answers
If you’re using distro’s own PHP imagick module, it will be impossible to use your own ImageMagick copy.
There are 2 ways to use your own ImageMagick:
I guess the second option would be much easier and more flexible than to compile the whole PHP. It’s best to keep using distro’s PHP, with all the security updates and patches delivered to you automatically, than to maintain your own binary.
To build the imagick PECL extension from source based on a non-standard ImageMagick installation directory you need to specify the directory using the
--with-imagick
argument of the extension’sconfigure
script.However, the
pecl
command provides more user-friendly way to install PECL extensions. Here is how you can install both the ImageMagick package and the imagick PECL extension:The command will ask to provide a path to the ImageMagick installation directory. Paste the ImageMagick installation directory here (replace
/home/johndoe/usr/lib/imagemagick
with your path):Then add
extension=imagick.so
to php.ini or run PHP CLI with-d 'extension=imagick.so'
arguments, e.g.: