How to determine the color space of an image in Java?

I am trying to determine the color space of an image in Java. I believe this is called "imageType" in the BufferedImage class. This is the line of code that causes me problems - I don’t know what to add as the third argument:

BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 

I am going to stitch several images together in a BufferedImage using the Graphics2D class. Some images I use may be in RGB format, others in ARGB, 4-byte ARGB, etc.

Is there any way to programmatically determine the color spaces of images? Or, if not, is there a way to convert all the images into the same color space before stitching?

+4
source share
1 answer

The ColorConvertOp class can be used to convert an image from one ColorSpace to another.

BufferedImage.getType() can be used to determine the color space used by the image.

+2
source

All Articles