title: Dealing with Adobe CMYK jpegs and Bufferedimage in java
body: <p>Im trying to apply the code posted in this post:
  <a href="https://stackoverflow.com/questions/3123574/how-to-convert-from-cmyk-to-rgb-in-java-correctly">How to convert from CMYK to RGB in Java correctly?</a>
  The Answer from the guy named Codo works for me so far, but my source is not a file, its an object that gets converted into a BufferedImage with</p>
  
  <pre><code>stream = (PRStream)object;
  PdfImageObject image = new PdfImageObject(stream);
  //this does not work
  BufferedImage bi = image.getBufferedImage();
  </code></pre>
  
  <p>The guy has a method that returns a BufferedImage from a file like so</p>
  
  <pre><code>public BufferedImage readImage(File file) throws IOException, ImageReadException
  </code></pre>
  
  <p>but i want to use </p>
  
  <pre><code>BufferedImage bi = readImage(image.getBufferedImage());
  </code></pre>
  
  <p>instead of  </p>
  
  <pre><code>File f = new File("/Users/adlib/Documents/projekte/pdf_compress/envirement/eclipse_luna/WORKSPACE/PDFCompression/src/Bild.jpg");
  BufferedImage bi = readImage(f);
  </code></pre>
  
  <p>cause im ectracting all the images from a pdf file using iText.
  I messed around with the code (changed file to BufferedImage and added streams) but a just dont get it to work. The File as Input image works fine, but not really what i need. What do i need to change to get This guys code to work with BufferedImage as input for the readImage() method?</p>
  
  <p>Here is the complete code of this guy
  <a href="https://stackoverflow.com/a/12132630/4944643">https://stackoverflow.com/a/12132630/4944643</a></p>
  
  <p>He uses Sanselan / Apache Commons Imaging</p>