ImageMagick +jmagick Installation

Source: Internet
Author: User
Tags imagemagick



First, the premise introduction

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's C interface directly using Java via 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.

Jmagick not suitable for use in Web applications, see: the Jni-hazard problem of Jmagick

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.


Second, installation support library

Linux server if you do not install the JPEG v6b, LibPng, FreeType Library, to install the ImageMagick before the installation, otherwise ImageMagick can not read JPEG and PNG pictures, font files can not read.

Yum Remove ImageMagick

Yum install libjpeg libjpeg-devel libpng libpng-devel libtiff libtiff-devel libungif libungif-devel freetype zlib-y


Third, install ImageMagick and Jmagick on Linux using the source code

Installing ImageMagick

: ftp://gd.tuwien.ac.at/pub/graphics/ImageMagick/ImageMagick-6.7.5-0.tar.gz

Tar xzf imagemagick-6.7.5-0.tar.gz
CD imagemagick-6.7.5-0
./configure
Make
Make install
Ldconfig/usr/local/lib

/usr/local/bin/convert Logo:logo.gif


Installing Jmagick

Yum Install git
git clone Https://github.com/techblue/jmagick

CD Jmagick

Whereis Java

./configure--prefix=/opt/jmagick--with-java-home=/opt/jdk1.7.0_71/--with-magick-inc-dir=/opt/ Imagemagick-6.7.5-0/include/imagemagick

Make
Make install

Convert--version


Iv. final

1, edit the PATH environment variable inside the/etc/profile, add in the last side:
Export Path=/usr/local/imagemagick/bin: $PATH
Ld_library_path=/usr/local/lib
Export Ld_library_path

2. Edit/etc/ld.so.conf:
Found: include ld.so.conf.d/*.conf
Modified to:
Include Ld.so.conf.d/*.conf/usr/local/imagemagick/lib
Added: "Space" + "/usr/local/imagemagick/lib"
Execute command:
Ldconfig

3, after the configuration is completed, enter the/root/jmagic/lib directory,
A total of three files:
Jmagick-6.7.7.jar

Libjmagick-6.7.7.so

Libjmagick.so./libjmagick-6.7.7.so

and copy the so file to the jre/lib/i386 (64-bit: AMD64 folder) folder of your JDK installation directory.
CP LIBJMAGICK-6.7.7.SO/OPT/JDK1.7.0_71/JRE/LIB/AMD64
Cd/opt/jdk1.7.0_71/jre/lib/amd64

MV Libjmagick-6.7.7.so libjmagick.so
This completes the installation of the ImageMagick, and next we install the Java application Interface Jmagick it provides.
Copy the jar file under the/usr/local/jmagic/lib directory to the Web-info/lib or resin/lib of the project

Basically done.

In fact, this is the Java program to call the time to know the results.


Copy the jar file under the/usr/local/jmagic/lib directory to the Web-info/lib or resin/lib of the project

This should be under the webinfo of the re-development package.

After the installation is successful, the/root/jmagick-6.7.7/lib/ There is a Jmagick-6.7.7.jar file that uses this jar file in your Java project to process the picture, and you need to move the Jmagick-6.7.7.jar file to the Tomcat Bin directory with the following command:
# MV *.jar/usr/local/tomcat/apache-tomcat-6.0.35/bin


Five, test the installation is normal

Enter the ImageMagick installation directory, Cd/opt/magemagick/bin

Convert Logo:logo.png
Convert Logo:logo.gif
Convert logo:logo.jpg
Convert Logo:logo.jpeg

# CD imagemagick-6.7.5-0/
Ls
Etc include Lib Logo.gif share

To copy the generated files logo.gif local after viewing the diagram, it indicates that all installations are normal.


Start testing

. Test the command line using the method:
Convert-resize 100x200 22.jpg (picture path) 11.jpg (store path after zooming) picture proportionally scaled
Convert-resize 100x200\! 22.jpg (picture path) 11.jpg (store path after zooming) forces the zoom to a given width and height
Convert-crop 100 (Long) x200 (h) +10 (x-coordinate) +10 (y-coordinate) 22.jpg (picture path) 11.jpg (store path after zooming) cropping a picture




ImageMagick +jmagick Installation

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.