Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Java ImageIO Chroma Subsampling

I'm attempting to save a BufferedImage as JPEG using ImageIO. But even when saving using 100 quality, I am suffering quality loss due to Chroma SubSampling.

I have successfully fixed this issue by reverting to the older JAI libraries and explicitly setting the Horizontal and Vertical Subsampling to 1. However a critical requirement is that I save the image as Progressive, which JAI doesn't seem to support.

Is there a way to disable sub-sampling using the newer ImageWriter?

Thanks in advance

If possible, I'd like to avoid ImageMagick

like image 555
ejthurgo Avatar asked Nov 02 '25 07:11

ejthurgo


1 Answers

A reading of JPEG Metadata Format Specification and Usage Notes seems to suggest that this is possible by writing the image with a custom IIOMetadata.

A search on the internet brings up https://codereview.appspot.com/3082041/patch/204004/210007, which seems to use ImageIO in exactly this manner.

I haven't tried it, and have no idea if it actually works.

like image 95
yiding Avatar answered Nov 03 '25 21:11

yiding



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!