Java如何将RGB图片转化为CMYK图片

首先声明:

  • 只有jpeg才支持cmyk
  • 默认Java是不能读取cmyk的jpg的,需要用

这里讨论的是如何在内存中把rgb转为cmyk

// 假设file是png的,即rgb的
BufferedImage img = ImageIO.read(file);

ColorSpace cpace = new ICC_ColorSpace(
                                ICC_Profile.getInstance("/home/coder4/Downloads/JapanColor2001Uncoated.icc")
                        );

ColorConvertOp op = new ColorConvertOp(img.getColorModel().getColorSpace(), cpace, null);
img = op.filter(img, null);

// 此时img就是cmyk了

各种profile可以在这里下载:https://github.com/cjw-network/cjwpublish1411/tree/master/vendor/imagine/imagine/lib/Imagine/resources/Adobe/CMYK

Leave a Reply

Your email address will not be published. Required fields are marked *