diff --git a/commons-component-common/src/main/java/org/exoplatform/services/thumbnail/ImageResizeServiceImpl.java b/commons-component-common/src/main/java/org/exoplatform/services/thumbnail/ImageResizeServiceImpl.java index c88ed183af..503f70faa6 100644 --- a/commons-component-common/src/main/java/org/exoplatform/services/thumbnail/ImageResizeServiceImpl.java +++ b/commons-component-common/src/main/java/org/exoplatform/services/thumbnail/ImageResizeServiceImpl.java @@ -24,8 +24,10 @@ import javax.imageio.IIOImage; import javax.imageio.ImageIO; import javax.imageio.ImageReader; +import javax.imageio.ImageWriteParam; import javax.imageio.ImageWriter; import javax.imageio.metadata.IIOMetadata; +import javax.imageio.plugins.jpeg.JPEGImageWriteParam; import javax.imageio.stream.ImageInputStream; import org.imgscalr.Scalr; @@ -119,7 +121,11 @@ private byte[] toByteArray(BufferedImage targetBufferedImage, ImageReader source writer.setOutput(ImageIO.createImageOutputStream(byteArrayOutputStream)); IIOMetadata metadata = sourceImageReader.getImageMetadata(0); - writer.write(new IIOImage(targetBufferedImage, null, metadata)); + ImageWriteParam param = writer.getDefaultWriteParam(); + if (param instanceof JPEGImageWriteParam) { + ((JPEGImageWriteParam) param).setOptimizeHuffmanTables(true); + } + writer.write(null,new IIOImage(targetBufferedImage, null, metadata), param); writer.dispose(); return byteArrayOutputStream.toByteArray(); }