how to compress a PNG image using Java

后端 未结 4 1218
孤街浪徒
孤街浪徒 2020-12-10 12:18

Hi I would like to know if there is any way in Java to reduce the size of an image (use any kind of compression) that was loaded as a BufferedImage and is going to be saved

4条回答
  •  心在旅途
    2020-12-10 12:43

    Have a look at the ImageWriterParam class in the same package as the ImageIO class. It mentions compression.

    https://docs.oracle.com/javase/7/docs/api/javax/imageio/ImageWriteParam.html

    Also look at the example at http://exampledepot.com/egs/javax.imageio/JpegWrite.html and see if it translates well for PNG files.

提交回复
热议问题