Skip to content

Instantly share code, notes, and snippets.

@ARolek
Last active February 10, 2023 00:07
Show Gist options
  • Star 31 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save ARolek/9199329 to your computer and use it in GitHub Desktop.
Save ARolek/9199329 to your computer and use it in GitHub Desktop.
Install ImageMagick from source on Amazon Linux

I needed a newer version of ImageMagick than is available on the yum packages on Amazon Linux. I tried using the remi repo but it failed with dependency errors. Here is what I did to install ImageMagick with support for PNG, JPG, and TIFF.

download the most recent package

wget http://www.imagemagick.org/download/ImageMagick.tar.gz

uncomress the package

tar -vxf ImageMagick.tar.gz

install the devel packages for png, jpg, tiff. these are dependencies of ImageMagick

sudo yum -y install libpng-devel libjpeg-devel libtiff-devel

configure ImageMagick without X11. this is a server without a display (headless) so we don't need X11

cd ImageMagick
./configure --without-x
make && make install

mission complete.

@samsamm777
Copy link

This worked perfectly! Thanks!

@ARolek
Copy link
Author

ARolek commented Jul 10, 2014

@samsamm777 glad it could help. I just referenced it today again. I need to write more stuff down ;-)

@danielroy
Copy link

Thanks, this saved me so much pain!

@Ravean
Copy link

Ravean commented Mar 6, 2015

This almost worked as described but I had to do:

make
sudo make install

However I ran into problems when trying to use imagemagick with php. I was getting the following errors in the /var/log/httpd/error_log after restarting apache:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/imagick.so' - libMagickWand.so.5: cannot open shared object file: No such file or directory in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/imagick.so' - libMagickCore.so.5: cannot open shared object file: No such file or directory in Unknown on line 0

ldd on imagick.so showed:

ldd imagick.so
        libMagickWand.so.5 => not found
        libMagickCore.so.5 => not found

I had to create a symlink to like this to the libMagick files:

sudo ln -s /usr/local/lib/libMagickCore-6.Q16.so.2.0.0 libMagickCore.so.5
sudo ln -s /usr/local/lib/libMagickWand-6.Q16.so.2.0.0 libMagickWand.so.5

Everything seems to be working now. Hope this helps someone else with the same problem.
Thanks!

@kendantinio
Copy link

Got this problem on live amazon ec2 linux

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/5.6/modules/imagick.so' - /usr/lib64/php/5.6/modules/imagick.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Fatal error: Class 'Imagick' not found in /var/www/html/test/imagick/index.php on line 2

@kendantinio
Copy link

Got this problem on live amazon ec2 linux

PHP Fatal error: Class 'Imagick' not found in /var/www/html/test/imagick/index.php on line 2

Using this code
$imagick = new Imagick();
var_dump($imagick);
$imagick->readImage('test.pdf');
$imagick->writeImages('testone.jpg', false);
echo 'Aw';

@mariosanchez23
Copy link

I tried in a clean aws machine and it didn't work.
I needed to use curl instead of wget
and the run
yum groupinstall "Development tools"

because I was getting errors calling the ./configure --without-x
The error was>
configure: error: in `/home/ec2-user/ImageMagick-7.0.1-5':
configure: error: no acceptable C compiler found in $PATH

at last I needed to do sudo for make && make install

@gweiss27
Copy link

gweiss27 commented Jun 8, 2016

This was a godsend! Thank You!!!! (I also had to sudo pretty much everything). I chose to installed the latest 6.9.4-8 version and then uninstalled and reinstalled imagick (and restarted apache). Now it seems like I'm all upgraded!

Love smart people who help others out! :)

@AljoSt
Copy link

AljoSt commented Jun 30, 2016

Thanks!

@pdbreen
Copy link

pdbreen commented Sep 14, 2016

Thanks. This got me most of the way there for an upgrade on ec2 running php70! Since I was after webp support, I also installed the libwebp-devel (and giflib-devel for good measure). And, when done, I had to reinstall imagick via pecl instead of yum. Complete steps for me ended up being this:

sudo yum install libpng-devel libjpeg-devel libtiff-devel libwebp-devel giflib-devel

cd
wget http://www.imagemagick.org/download/ImageMagick.tar.gz
tar -vxf ImageMagick.tar.gz
cd ImageMagick-7.0.3-0/
./configure --without-x
make
sudo make install

sudo service nginx stop
sudo service php-fpm stop

sudo yum install php70-devel
sudo pecl install imagick

php -v

sudo service php-fpm start
sudo service nginx start

@Said210
Copy link

Said210 commented Sep 12, 2017

Nice, thank you (y)

@p-j-vlad
Copy link

p-j-vlad commented Nov 25, 2017

I'm running Amazon EC2 with AWS Linux on it. I tired the instructions from pdbreen and I'm getting an error right after executing ./configure:
./configure --without-x

Right after that I get this error:
configure: error: in `/var/www/html/ImageMagick-7.0.7-11':
configure: error: no acceptable C compiler found in $PATH

Adding the compiler fixed the issue:
yum install gcc gcc-c++ autoconf automake

Thanks.
PV.

@Rybots
Copy link

Rybots commented Jul 15, 2018

It helps me a lot.! You're out of this world! Thanks!!!!!!!

@wassgha
Copy link

wassgha commented Aug 2, 2018

If it complains about "delegates library support not built-in" (freefont or others), install ImageMagick-devel before executing sudo make :

sudo yum install ImageMagick-devel

@raj-chef
Copy link

If anyone doesn't wanna compile then you can follow this process to install it via rpm packages.

sudo yum install libpng-devel libjpeg-devel libtiff-devel libwebp-devel giflib-devel

Download these files

sudo yum install ImageMagick-c++-devel-7.0.10-0.x86_64.rpm ImageMagick-c++-7.0.10-0.x86_64.rpm ImageMagick-devel-7.0.10-0.x86_64.rpm ImageMagick-7.0.10-0.x86_64.rpm ImageMagick-libs-7.0.10-0.x86_64.rpm fribidi-1.0.2-1.el7.x86_64.rpm fribidi-devel-1.0.2-1.el7.x86_64.rpm

files can be downloaded from here
https://imagemagick.org/download/linux/CentOS/x86_64/
https://rpmfind.net/linux/rpm2html/search.php?query=fribidi*&submit=Search+...&system=centos&arch=

@igal1c0de4n
Copy link

igal1c0de4n commented Feb 25, 2021

@raj-chef I tried the approach you mentioned. Looks like the binaries available are one version up.
On my end the rpms are not installing. I get the error below. Ideas?

$ uname -a
Linux ip-<some ip addr>.amzn1.x86_64 #1 SMP Sun Jan 10 10:40:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

$ sudo yum install ImageMagick-libs-7.0.11-1.x86_64.rpm
...
--> Finished Dependency Resolution
Error: Package: ImageMagick-libs-7.0.11-1.x86_64 (/ImageMagick-libs-7.0.11-1.x86_64)
           Requires: libIlmImf-2_2.so.22()(64bit)
Error: Package: ImageMagick-libs-7.0.11-1.x86_64 (/ImageMagick-libs-7.0.11-1.x86_64)
           Requires: libwebp.so.7()(64bit)
Error: Package: ImageMagick-libs-7.0.11-1.x86_64 (/ImageMagick-libs-7.0.11-1.x86_64)
           Requires: libwebpmux.so.3()(64bit)
Error: Package: ImageMagick-libs-7.0.11-1.x86_64 (/ImageMagick-libs-7.0.11-1.x86_64)
           Requires: libpng16.so.16()(64bit)
Error: Package: ImageMagick-libs-7.0.11-1.x86_64 (/ImageMagick-libs-7.0.11-1.x86_64)
           Requires: libgs.so.9()(64bit)
Error: Package: ImageMagick-libs-7.0.11-1.x86_64 (/ImageMagick-libs-7.0.11-1.x86_64)
           Requires: libraqm.so.0()(64bit)
Error: Package: ImageMagick-libs-7.0.11-1.x86_64 (/ImageMagick-libs-7.0.11-1.x86_64)
           Requires: libIex-2_2.so.12()(64bit)
Error: Package: ImageMagick-libs-7.0.11-1.x86_64 (/ImageMagick-libs-7.0.11-1.x86_64)
           Requires: libIlmThread-2_2.so.12()(64bit)
Error: Package: ImageMagick-libs-7.0.11-1.x86_64 (/ImageMagick-libs-7.0.11-1.x86_64)
           Requires: libpng16.so.16(PNG16_0)(64bit)
Error: Package: ImageMagick-libs-7.0.11-1.x86_64 (/ImageMagick-libs-7.0.11-1.x86_64)
           Requires: libgdk_pixbuf-2.0.so.0()(64bit)
Error: Package: ImageMagick-libs-7.0.11-1.x86_64 (/ImageMagick-libs-7.0.11-1.x86_64)
           Requires: libHalf.so.12()(64bit)
Error: Package: ImageMagick-libs-7.0.11-1.x86_64 (/ImageMagick-libs-7.0.11-1.x86_64)
           Requires: libImath-2_2.so.12()(64bit)
Error: Package: ImageMagick-libs-7.0.11-1.x86_64 (/ImageMagick-libs-7.0.11-1.x86_64)
           Requires: librsvg-2.so.2()(64bit)
Error: Package: ImageMagick-libs-7.0.11-1.x86_64 (/ImageMagick-libs-7.0.11-1.x86_64)
           Requires: libraw_r.so.19()(64bit)
Error: Package: ImageMagick-libs-7.0.11-1.x86_64 (/ImageMagick-libs-7.0.11-1.x86_64)
           Requires: libIexMath-2_2.so.12()(64bit)
Error: Package: ImageMagick-libs-7.0.11-1.x86_64 (/ImageMagick-libs-7.0.11-1.x86_64)
           Requires: libwebpdemux.so.2()(64bit)
Error: Package: ImageMagick-libs-7.0.11-1.x86_64 (/ImageMagick-libs-7.0.11-1.x86_64)
           Requires: libopenjp2.so.7()(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
 
  

@ARolek
Copy link
Author

ARolek commented Feb 26, 2021

I'm just amazed that this post from 7 years ago is still alive. Thanks for everyone continuing to post updated solutions.

@igal1c0de4n
Copy link

igal1c0de4n commented Mar 1, 2021

Not exactly helping people who insist on ImageMagick, but still may help someone reaching this thread:

I use GraphicsMagick npm pkg with ImageMagick for resizing and converting images in Elastic Beanstalk nodejs.

Locally on macos the code successfully resizes/converts jpg, png, webp formats.

Same code deployed on AWS Elastic Beanstalk: JPEG/PNG formats convert successfully, however WEBP images are identified as PAM images, essentially breaking the ability to resize/convert them.

I consulted AWS support and eventually discovered a work around: dropping GM's ImageMagick mode .subClass({imageMagick: true} and not installing ImageMagick. After that, my nodejs instance worked correctly will the mentioned image formats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment