Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Jmagick JMagick Tutorial

Related Tutorials


 
 

Share on Google+Share on Google+

JMagick Tutorial

Advertisement
Learn how to download, install and create simple JMagick program through this tutorial.

JMagick Tutorial - Download, install and create simple program

JMagick library is Java library for handling the image in Java. It is implemented as thin Java Native Interface (JNI) layer to access the popular ImageMagick API. The ImageMagick API is written is C programming language. It is one of the most popular image handling library. ImageMagick  can be used to resize the image. It can also use to flip, mirror, rotate and even distort the input image. Beside these functionality it can also be used to shear and transform images.

Its import function includes adjustment of image colors, apply various special effects, or draw text etc... JMagick library allows you to perform these activity from the Java code also. In this tutorial I will teach you how you can use the JMagick library for manipulating the images.

Downloading and installing JMagick on windows

Step 1:  To Download the JMagick for windows operating system visit http://downloads.jmagick.org/6.3.9/.

Step 2: Download the file ImageMagick-6.3.9-0-Q16-windows-dll.exe and install on your computer. Add the installation path in the patch variable of your computer.

Step 3: Download jmagick-win-6.3.9-Q8.zip and unzip. The directory contains jmagick.jar and jmagick.dll.

Step 4: Add jmagick.jar is in the Java classpath.

Step 5: Copy jmagick.dll into jre\bin and JDK\lib directories

Now you can compile and run your program based on JMagick.

Example of JMagick that writes text on the image.

Blow is the program that writes the text on the image:

import java.io.*;
import java.awt.*;
import magick.*;

class InsertText
{
	public static void main(String a[]) throws IOException,MagickException
	{
		ImageInfo info=new ImageInfo("test.jpg");
		MagickImage image=new MagickImage(info);
		DrawInfo aInfo = new DrawInfo(info);
		aInfo.setFill(PixelPacket.queryColorDatabase("yellow"));
		//aInfo.setUnderColor(PixelPacket.queryColorDatabase("red"));

		aInfo.setOpacity(100);
		aInfo.setPointsize(36);
		aInfo.setFont("Arial");

		aInfo.setGeometry("+50+50");
		aInfo.setText("JMagick Tutorial");

		image.annotateImage(aInfo);
		image.setFileName("text.jpg");
		image.writeImage(info); 
	}

}

In this tutorial you have learned how to download, install and create simple program using JMagick library.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 31, 2013

Related Tutorials

Discuss: JMagick Tutorial  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:1
Arun
September 1, 2014
Can i get Alpha Channel details from JMagic

Can i get Alpha Channel details from JMagic
DMCA.com