Linux-side Graphics processing tool ImageMagick installation on CentOS

Source: Internet
Author: User
Tags imagemagick

First, installation background
Program to use the user upload pictures, editing functions, can be rotated, cut, zoom and so on.

Ii. introduction of ImageMagick

ImageMagick is the development of the image processing program in C language. You can resize, rotate, sharpen, subtract, or add effects to a picture. The operation of the picture can be done through the command line, or by programming with C + +, Perl, Java, PHP, Python, or Ruby.
ImageMagick's official website is: http://www.imagemagick.org/script/index.php
Since we are a Java project, it is not possible to call ImageMagick directly from Java using JNI technology. Because ImageMagick was developed without a header file generated using Java JNI. You can use Jmagick to resolve, Jmagick is developed by the C language, and development uses a Java JNI generated header file, so Java can call Jmagick through JNI technology. Jmagick call ImageMagick again. We're dealing with images using the Jmagick exposed Java interface. You can also use JNA to invoke Imagemagick,jna full name is Java Native Access,jna is perfect on the basis of JNI, convenient for us to develop. The JNA Project home page is Https://github.com/twall/jna. Using JNA to invoke ImageMagick requires direct manipulation of the C interface (API) provided by ImageMagick.

Third, ensure that the system has installed the following packages
# yum Install Libjpeg
# yum Install Libjpeg-devel
# yum Install libpng
# yum Install Libpng-devel
# yum Install Libtiff
# yum Install Libtiff-devel
# yum Install Libungif
# yum Install Libungif-devel
# yum Install FreeType
# yum Install zlib

Can be viewed with the following command
#rpm-qa |grep Libjpeg

If not installed, install the above dependency package via the Yum command

Iv. installation ImageMagick does not differentiate between 32-bit, 64-bit operating systems

There are two ways to install, the first is to install the RPM method directly, this method is also recommended by this article
The second way is to install it in a compiled way, with no special requests or RPM installation
1, yum mode installation, the following:
# If you have previously installed, uninstall the ImageMagick:
#yum Remove ImageMagick
#yum Install ImageMagick
2, compile the way to install
Download the version you need to install from the http://downloads.jmagick.org/6.4.0/URL, and the files you can download include the following
imagemagick-6.4.0-0.tar.gz 24-mar-2008 00:15 11M
jmagick-6.4.0-3.i386.rpm 05-jun-2009 09:27 172K
jmagick-6.4.0-3.src.rpm 05-jun-2009 09:27 524K
jmagick-6.4.0-3.x86_64.rpm 05-jun-2009 09:27 65K
jmagick-6.4.0-src.tar.gz 11-feb-2009 10:27 521K
jmagick-debuginfo-6.4.0-3.x86_64.rpm 05-jun-2009 09:27 135K
jmagick-linux-6.4.0-q8.tar.gz 08-dec-2008 19:27 56K
jmagick-linux-6.4.0-q16.tar.gz 08-dec-2008 19:27 56K
jmagick-linux-6.4.0-q32.tar.gz 08-dec-2008 19:27 56K
According to your own needs to install the corresponding version of the ImageMagick, the specific code is as follows
#tar ZXVF imagemagick-6.4.0-0.tar.gz
#cd ImageMagick-6.4.0
#./configure--enable-shared--without-perl (if not, use./configure)
#make
#make Install
#make Check
3. A convert is generated when the installation is complete
#find/-name Convert
#convert--version

You can determine whether the installation was successful based on the results you viewed. You can then try to use the Convert command at the command line
#convert-geometry 100x200 source files. jpg after processing files. GIF (format conversion),
Add
1. If the following error is reported
{[Error:command Failed:convert:no decode Delegate for this image format ' JPEG ' @ error/constitute.c/readimage/501.
Convert:no images defined '/home/node/head/i/img_0005.jpg ' @ error/convert.c/convertimagecommand/3230.
] Code:1, Signal:null}
Note that our conversion tool does not support the format of this type of image, which can be confirmed with the command identify-list format.
Workaround you can download the corresponding library to this URL http://www.imagemagick.org/download/delegates/
JPG or PNG formats are available. After download
Extract
Tar zvxf libjpeg-6b.tar.gz
#安装
CD ~/zlib-1.2.7
./configure
Make
Make install
Supposedly this should be able to support the JPG format, but I actually test the time is still unsuccessful, and then added the next step, just become.
Re-install ImageMagick
Make Uninstall
./configure
Make
Make install
The call succeeds again.
V. Installation of Jmagick

Installation of the premise is to download the above step three, install ImageMagick in 2 said the installation package
1, installation of dependent libraries, etc.
Note: Whether or not you have your own jre/jdk feel this or must have, otherwise the installation RPM will be prompted to find the relevant Java library
Note: When installing JMAGICK-SRC, if you do not have this Jman account, an error will be installed
The shell code is as follows:
# yum install Java;
#/usr/sbin/useradd–u 1000–s/sbin/nologin Jman;
2, 32-bit operating system RPM mode installation Jmagick,shell code is as follows:
# RPM–IVH jmagick-6.4.0-3.i386.rpm
# RPM–IVH jmagick-6.4.0-3.src.rpm
3, 64-bit operating system RPM mode installation Jmagick,shell code is as follows:
# RPM–IVH jmagick-6.4.0-3.x86_64.rpm
# RPM–IVH jmagick-6.4.0-3.src.rpm
# RPM–IVH jmagick-debuginfo-6.4.0-3.x86_64.rpm
32-bit operating system no jmagick-debuginfo-6.4.0-3.x86_64.rpm files
4. The following error occurs if installing SRC
[Email protected] ~]# RPM-IVH jmagick-6.4.0-3.src.rpm
Error:cannot Create%sourcedir/usr/src/redhat/sources
The following statement is executed to
[Email protected] ~]# Mkdir/usr/src/redhat
[Email protected] ~]# mkdir/usr/src/redhat/sources
5, compile the way to install Jmagick, do not distinguish between 32-bit or 64-bit, the specific shell code is as follows:
Tar zvxf jmagick-6.4.0-src.tar.gz
CD JMAGICK-6.4.0-SRC
./configure--prefix=/opt360/jmagick-6.4.0
--with-java-home=/usr/local/java/jdk1.6.0_30
--with-magick-home=/opt360/imagemagick-6.4.0
Make all
Make install
After the installation is successful, the/opt360/jmagick-6.4.0/lib/ There is a Jmagick-6.4.0.jar file that uses this jar file in your Java project to process the picture, and you need to move the Jmagick-6.4.0.jar file to the Tomcat Bin directory with the following command:
# MV *.jar/usr/local/apache-tomcat-6.0.35/bin
Remember that Jmagick-6.4.0.jar is compiled with the jdk1.6 you specified earlier, so you cannot use Jmagick-6.4.0.jar in a JDK 1.5 environment.
If you execute make Javadoc, there is a document in the/opt360/jmagick-6.4.0/share/doc directory.

Troubleshooting problems that occur during installation
1. If the following error occurs during installation:
error:failed dependencies:
JRE is needed by jmagick-6.4.0-3.i386
Instructions not installed in step 1 above, install JRE/JDK, please install and try again
2, if you want to test the program or project under Tomcat, please restart Tomcat after the test, I did not restart Tomcat, test several times or error, and finally restart the tomcat to be done.

Linux-side Graphics processing tool ImageMagick installation on CentOS

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.