How to set icc color profile in Java and change color space

Firstly, I would like to say that I am not an image processing specialist.

I would like to convert the color space of an image from one to another and at the same time change the color profile of icc. I managed to do this using JMagick (Java port of ImageMagick), but not in pure Java (even using JAI).

+3
source share
1 answer

Use ColorConvertOpthis to do the color space conversion. You have several options for setting the icc color profile. Either you use a predefined profile using getInstancethe correct color space constant, or you can specify a file containing the profile. Here is an example:

ICC_Profile ip = ICC_Profile.getInstance( ColorSpace.CS_sRGB );
ICC_ColorSpace ics = new ICC_ColorSpace( ip );
ColorConvertOp cco = new ColorConvertOp( ics, null );
BufferedImage result = cco.filter( sourceImage, null );

resultwill contain an image with color space sRGB.

+5
source

Source: https://habr.com/ru/post/1530963/


All Articles