I am writing a program in Java using JMagick, and I need to be able to compress the image(lower the filesize) by lowering the quality of the image. I have tried the info.setQuality(99) and info.setQuality(1) classes but there is no difference in the size of the outputfile.
Is there a way to increase and decrease the quality of the image and thus adjusting the filesize of the outputfile with JMagick?
Thanks in advance. Sorry for the bad formatting.
import java.io.*;
import magick.*;
public class jpgconverter {
/**
* @param args
* @throws MagickException
* @throws IOException
*/
public static void main(String[] args) throws MagickException, IOException {
int pixels = 500;
ImageInfo info = new ImageInfo("/home/bram/Downloads/verborgenlagen.jpg");
MagickImage converter = new MagickImage(info);
double currentHeight = converter.getDimension().getHeight();
double currentWidth = converter.getDimension().getWidth();
if(currentWidth > currentHeight) {
currentHeight = currentHeight * pixels / currentWidth;
currentWidth = pixels;
}else {
if(currentHeight > currentWidth) {
currentWidth = currentWidth * pixels / currentHeight;
currentHeight = pixels;
}
}
converter.setXResolution(72.00);
converter.setYResolution(72.00);
converter = converter.scaleImage((int)currentWidth, (int)currentHeight);
converter.setFileName("/home/bram/Downloads/verborgenlagenConverted.jpg");
converter.writeImage(info);
}
}