Thursday, 15 March 2012

jpeg - Changing Image resolution without resizing in Java -



jpeg - Changing Image resolution without resizing in Java -

i want compress jpeg image, is, decrease resolution, without resizing in way. there java library help me doing it? there lots of similar posts in so, of them end resizing image well.

if not, how can programatically? say, argument of 0.9, image's resolution decrease factor of 0.1...

typically "resolution" means size. mean jpeg quality instead? way can think of compress without resizing it.

if so, can utilize java2d imageio api. next work (adapted this page):

bufferedimage bufferedimage = imageio.read(...); imagewriter author = (imagewriter)imageio.getimagewritersbyformatname("jpeg").next(); imagewriteparam iwp = writer.getdefaultwriteparam(); iwp.setcompressionmode(imagewriteparam.mode_explicit); iwp.setcompressionquality(...); file file = new file(...); fileimageoutputstream output = new fileimageoutputstream(file); writer.setoutput(output); iioimage image = new iioimage(bufferedimage, null, null); writer.write(null, image, iwp); writer.dispose();

unfortunately, don't think there's way existing jpeg quality of image, you'll have utilize fixed value compression quality.

java jpeg image-compression

No comments:

Post a Comment