6

I have Ubuntu 18.04.1 LTS which comes with ImageMagick 6.9.7 by default and I wanted ImageMagick to process jp2 images so I installed libopenjp2-7-dev and also installed imagemagick7 from source like this:

wget https://www.imagemagick.org/download/ImageMagick.tar.gz 
tar xvzf ImageMagick.tar.gz
cd ImageMagick-7.0.10-22
./configure
make
sudo make install
sudo ldconfig /usr/local/lib

magick -version shows the right one:

Version: ImageMagick 7.0.10-22 Q16 x86_64 2020-07-02 https://imagemagick.org
Copyright: © 1999-2020 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP(4.5)
Delegates (built-in): jng jp2 jpeg png xml zlib

But in phpinfo() it shows:

imagick module version  3.4.4
imagick classes Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
Imagick compiled with ImageMagick version   ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org
Imagick using ImageMagick library version   ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org

I even tried to remove the ImageMagick 6.9.7 and the PHP-Imagick extension, I thought that by reinstalling the extension with only one version available, it will somehow point at that but the extension couldn't be installed without ImageMagick6. I'm out of ideas on how to make PHP use the ImageMagick 7.

GChuf
  • 560

2 Answers2

2

I think you're stuck with ImageMagick v6.x for now. The important thing here is the imagick module itself. Regardless of ImageMagick version on your system, the imagick module v3.4.4 only supports ImageMagick versions 6.x.

From the PECL imagick website (PHP Extension Community Library):

The 3.4.4 release is intended to be the last release (other than small bug fixes) 
that will support either PHP 5.x, or ImageMagick 6.x.
The next planned release will be PHP > 7.0 and ImageMagick > 7.0 at least, if not higher.

Link: http://pecl.php.net/package/imagick/3.4.4

GChuf
  • 560
2

You can use ImageMagick 7 with PHP by first installing ImageMagick 7 on your system and then compiling the PHP imagick extension as provided on the repo (https://github.com/Imagick/imagick):

Compile and Install ImageMagick 7:

sudo apt update
sudo apt build-dep imagemagick
wget https://www.imagemagick.org/download/ImageMagick.tar.gz
tar xf ImageMagick.tar.gz
cd ImageMagick-7*
./configure
make
sudo make install
sudo ldconfig /usr/local/lib

Compile and Install PHP imagick:

git clone https://github.com/Imagick/imagick  
cd imagick  
phpize && ./configure  
make  
make install  

The version used by PHP can be verified by calling Imagick::getVersion() in PHP