sejda-pdf / webp-imageio

Java ImageIO WebP support
Apache License 2.0
198 stars 74 forks source link

Compression size #11

Open jobartim44 opened 3 years ago

jobartim44 commented 3 years ago

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 commented 3 years ago

And the original file

FAR03005NB

lambdaupb commented 3 years ago

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