JPEG Quality

Hello all,

I open JPEG, make some transformations and want to save it again.

Is there any possibility to get the quality of the file I have opend and to save the JPEG with the same quality as it was created.

In other words I want to find out this quality param:

encParam.setQuality (1.0f, false);

Thanks in advance.

[352 byte] By [flexeda] at [2007-11-27 4:19:08]
# 1
No, JPEG is lossy even with quality setting 1.0.Quality is an application specific parameter. In other words, quality is a relative parameter.
rkippena at 2007-7-12 9:26:02 > top of Java-index,Security,Cryptography...
# 2

This code works for me:

ImageWriteParam iwparam = new JPEGImageWriteParam(Locale.getDefault());

iwparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);

iwparam.setCompressionQuality(compressionRate);//Set here your compression rate

ImageWriter iw = ImageIO.getImageWritersByFormatName("jpg").next();

ImageOutputStream ios = ImageIO.createImageOutputStream(file);//file is the file you want to create

iw.setOutput(ios);

iw.write(null, new IIOImage(rendImage, null, null), iwparam);

iw.dispose();

ios.close();

arno_ba at 2007-7-12 9:26:03 > top of Java-index,Security,Cryptography...