Created
March 19, 2016 16:34
-
-
Save chikien276/4f34eea0efb82d983c0f to your computer and use it in GitHub Desktop.
Convert jpeg image RGB colorspace to CMYK colospace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.color.ColorSpace; | |
import java.awt.color.ICC_ColorSpace; | |
import java.awt.color.ICC_Profile; | |
import java.awt.image.BufferedImage; | |
import java.awt.image.ColorConvertOp; | |
import java.io.File; | |
import javax.imageio.ImageIO; | |
/** | |
* | |
* @author Chikien | |
*/ | |
public class TestImage { | |
public static void main(String[] args) throws Exception { | |
BufferedImage rgbImage = ImageIO.read(new File( | |
"input/1.jpg")); | |
BufferedImage cmykImage = new BufferedImage(rgbImage.getWidth(), rgbImage.getHeight(), BufferedImage.TYPE_3BYTE_BGR); | |
ColorSpace cpace = new ICC_ColorSpace(ICC_Profile.getInstance("input/HP5000GlossExp05.icc")); | |
ColorConvertOp op = new ColorConvertOp(cpace, null); | |
cmykImage = op.filter(rgbImage, cmykImage); | |
ImageIO.write(cmykImage, "jpg", new File("input/1_converted.jpg")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment