Original address: http://www.iitshare.com/linux-install-imagemagick-jmagick.html
First, installation background
Recently deployed on the server HAPICMS products, because its compression of the picture is implemented using ImageMagick, so need to install ImageMagick and Jmagick on the server, the operation of the process is written down, and we share the next, which contains the RPM method of installation, linux32 bit installation ImageMagick and Jmagick, linux64 bit installation ImageMagick and Jmagick, if you have any questions can leave a message, time will be timely reply.
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
12345678910 |
# 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
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:
123 |
# 如果以前安装过,卸载掉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
123456789 |
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
123456 |
#tar zxvf ImageMagick- 6.4 . 0 - 0 .tar.gz #cd ImageMagick- 6.4 . 0 #./configure --enable-shared --without-perl(如果不行就用./configure) #make #make install #make check |
3. A convert is generated when the installation is complete
12 |
#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
1 |
#convert -geometry 100x200 源文件.jpg 处理后文件.gif (格式转换) |
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:
12 |
# 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:
12 |
# 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:
123 |
# 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
12 |
[root @localhost ~]# rpm -ivh jmagick- 6.4 . 0 - 3 .src.rpm error: cannot create %sourcedir /usr/src/redhat/SOURCES |
The following statement is executed to
12 |
[root @localhost ~]# mkdir /usr/src/redhat [root @localhost ~]# 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:
1234567 |
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:
1 |
# 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:
12 |
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.
The entire installation process ends here, so please read it.
Linux installation ImageMagick and Jmagick complete process and configuration