About ImageMagik
ImageMagick
is an open source software suite for displaying, converting, and editing raster
image files. It can read and write over 100 image file formats. ImageMagick is
licensed under the Apache 2.0 license.
Use
the convert program to convert between image formats as well as resize an
image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much
more.
Eg.
$magik>convert hello.jpg hello.png
This
command will convert file hello from jpg format to png format.
We
use convert.exe file to execute the conversion from a java path using
Runtime.exe or ProcessBuilder:
1.Using Runtime :
Process p = Runtime.getRuntime().exec("E:/ImageMagick-6.7.0-Q16/convert.exe E:/ImageMagick-6.7.0-Q16/logo.jpg E:/ImageMagick-6.7.0-Q16/logo.gif");
or
2.Using Processbuilder :
ProcessBuilder pb = new ProcessBuilder("E:/ImageMagick-6.7.0-Q16/convert.exe", "E:/ImageMagick-6.7.0-Q16/logo.jpg", "E:/ImageMagick-6.7.0-Q16/logo.gif");
Process start = pb.start();
Here , "E:/ImageMagick-6.7.0-Q16/' is the location of the ImageMagik directory.Location of images can be anything.
Process p = Runtime.getRuntime().exec("E:/ImageMagick-6.7.0-Q16/convert.exe E:/ImageMagick-6.7.0-Q16/logo.jpg E:/ImageMagick-6.7.0-Q16/logo.gif");
or
2.Using Processbuilder :
ProcessBuilder pb = new ProcessBuilder("E:/ImageMagick-6.7.0-Q16/convert.exe", "E:/ImageMagick-6.7.0-Q16/logo.jpg", "E:/ImageMagick-6.7.0-Q16/logo.gif");
Process start = pb.start();
Here , "E:/ImageMagick-6.7.0-Q16/' is the location of the ImageMagik directory.Location of images can be anything.