How to get color space of a jpeg/tiff in java?

2019-05-05 17:24发布

问题:

the title sums it up really. Using the standalone exiftool program to dump all image metadata to a console I can see a line Color Space Data : RGB It looks like this is taken from the ICC-header

I want to get the same data programatically in java. I've tried the drew noakes library and the Sanselan library, but neither give me a value of RGB for any field.

回答1:

You have a BufferedImage, right? If so, you probably want either getType() or getColorModel()(then .getColorSpace() or .toString()). You can test getType() against the various types defined in BufferedImage.