Configuring PNG on ImageMagick on a Linux Server

2019-06-27 09:24发布

问题:

I have been trying to run the following script on ImageMagick on a Linux server

convert resized.png -gravity Center -crop 1024X768+0+0 +repage flower.png

but have been hitting the following error:

convert: no decode delegate for this image format `PNG' @ error/constitute.c/ReadImage/501.
convert: no images defined `flower.png' @ error/convert.c/ConvertImageCommand/3212.

It looks like there is no delegate for PNG.

When I run:

identify -version

I get this result that shows that the PNG delegate is not installed:

Version: ImageMagick 6.9.0-4 Q16 x86_64 2015-01-25       http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates (built-in): bzlib freetype jpeg lcms tiff x zlib

As far as I can tell I have 'libpng' installed on my server.

How do I configure the PNG delegate for ImageMagick on my Linux server?

I have 'yum' installed but not 'apt-get'.

回答1:

I did a lot more searching and found this answer.

It looks like ImageMagick did not know what library to look for.

I did a

locate libpng

and found that it was located in

/usr/lib64/

I was then able to run the commands on this page (from within the ImageMagick directory):

http://www.imagemagick.org/discourse-server/viewtopic.php?t=12366

./configure --enable-shared
make libdir=/usr/lib64
make libdir=/usr/lib64 install
./configure --enable-shared=yes --x-libraries=/usr/lib64 --without-perl
make
make install

Then running

identify -version

showed the following results:

Version: ImageMagick 6.9.0-4 Q16 x86_64 2015-01-30
 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates (built-in): bzlib freetype jng jpeg lcms png tiff x zlib

which shows that PNG is now installed as a delegate.