Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your image "Color Model" is CMYK, <code>JPEGImageReader</code> (the inner class that reads your file) reads only RGB Color Model.</p> <p>If you insist on reading CMYK images, then you will need to convert them, try this code.</p> <p><strong>UPDATE</strong></p> <p>Read a CMYK image into RGB BufferedImage.</p> <pre><code> File f = new File("/path/imagefile.jpg"); //Find a suitable ImageReader Iterator readers = ImageIO.getImageReadersByFormatName("JPEG"); ImageReader reader = null; while(readers.hasNext()) { reader = (ImageReader)readers.next(); if(reader.canReadRaster()) { break; } } //Stream the image file (the original CMYK image) ImageInputStream input = ImageIO.createImageInputStream(f); reader.setInput(input); //Read the image raster Raster raster = reader.readRaster(0, null); //Create a new RGB image BufferedImage bi = new BufferedImage(raster.getWidth(), raster.getHeight(), BufferedImage.TYPE_4BYTE_ABGR); //Fill the new image with the old raster bi.getRaster().setRect(raster); </code></pre> <p><strong>UPDATE - March 2015 - Adding simulation images</strong></p> <p>Original images were removed from OP's dropbox. So I'm adding new images (not the originals) that simulates the problem that was happening with them.</p> <p><strong>First image</strong> is how a normal RGB image looks like.</p> <p><img src="https://i.imgur.com/AD5NOgEm.jpg" alt="Image RGB"></p> <p><strong>Second image</strong> is how the same image will look like in CMYK color model.</p> <p>You cannot actually see how it looks on the web because it will be converted to RGB by the host. To see exactly how it looks, take the RGB image and run it through an RGB to CMYK converter.</p> <p><strong>Third image</strong> is how the CMYK image will look like when read then written using Java ImageIO.</p> <p><img src="https://i.imgur.com/NCdLB7hm.jpg" alt="Image CMYK read through Java RGB"></p> <p>The problem that was happening with OP is they had something like image 2 which throws an exception when you try to read it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload