webp-imageio icon indicating copy to clipboard operation
webp-imageio copied to clipboard

Compression size

Open jobartim44 opened this issue 4 years ago • 2 comments
trafficstars

Hi, i'am trying to use the lib to automaticaly convert jpg files to webp to obtain smaller files. My problem is that the output file is the same weight even if it smaller in size (I previously resized the picture).

image

I'am doing this under Windows system with this code :

ImageWriter writer = ImageIO.getImageWritersByMIMEType("image/webp").next();

WebPWriteParam writeParam = new WebPWriteParam(writer.getLocale());
writeParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
writeParam.setCompressionType(writeParam.getCompressionTypes()[WebPWriteParam.LOSSLESS_COMPRESSION]);

writer.setOutput(new FileImageOutputStream(outputFile));

writer.write(null, new IIOImage(bufferedImage, null, null), writeParam);

jobartim44 avatar Dec 03 '20 16:12 jobartim44

And the original file

FAR03005NB

jobartim44 avatar Dec 03 '20 19:12 jobartim44

You won't get good results with WebPWriteParam.LOSSLESS_COMPRESSION, it means WebP can't really compress much.

lambdaupb avatar Jan 04 '21 02:01 lambdaupb