import java.awt.color.ColorSpace; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.lang.reflect.Field; import javax.media.jai.JAI; import com.sun.media.jai.codec.FileSeekableStream; import com.sun.media.jai.codec.SeekableStream; public class DetectColorSpace { public static void main(String[] args) { getColorSpaceFromImg("CMYK_img.jpg"); } private static void getColorSpaceFromImg(String path) { File file = new File(path); BufferedImage img = null; SeekableStream seekableStream = null; try { seekableStream = new FileSeekableStream(file); img = JAI.create("Stream", seekableStream).getAsBufferedImage(); } catch (IOException e) { e.printStackTrace(); } int type = img.getColorModel().getColorSpace().getType(); // determining the human readable name of the color space variable Class cs = ColorSpace.class; Field[] fields = cs.getDeclaredFields(); for (Field f : fields) { try { int fieldValue = (int) f.get(null); if (fieldValue == type) System.out.println("Farbraum: " + f.getName() + ", Variablenwert: " + fieldValue); } catch (IllegalArgumentException | IllegalAccessException e) { } } } }