My batch jpg resizer works with color images, but grayscale ones become washed out

二次信任 提交于 2019-12-01 12:39:20

If jdk's classes and methods are buggy, report the bug to oracle (oh! I wish I could go on saying to SUN..).

And, while the next release will correct the bug ;), try some work arounds, scaling image by yourself like proposed here.

Regards, Stéphane

In your code, you assume jpeg are encoded in RGB, but that's not always the case. It's also possible to encode 8 bit gray scaled jpeg. So I suggest that you try this when building your BufferedImage, replace :

BufferedImage.TYPE_INT_RGB;

by

BufferedImage.TYPE_BYTE_GRAY;

and see if it works for those images.

If so, then you still have to find out a way to determine the encoding type to automatically change the type of BufferedImage color encoding to use, but you will be one stop closer.

Regards, Stéphane

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!