title: Image == null! in ImageIO.read from ByteArrayInputStream
body: <p>I'm trying to compress an image using Run Length encoding and SAVE it as JPEG.</p>
  
  <p>But when i try to read BufferedImage from BYteArrayInputStream the program fails, returning following at line below (BufferedImage bImage2 = ImageIO.read(bis);) cus the ImageIO.read(bis) returns null - bis is not null:</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalArgumentException: image == null!
  at javax.imageio.ImageTypeSpecifier.createFromRenderedImage(ImageTypeSpecifier.java:925)
  at javax.imageio.ImageIO.getWriter(ImageIO.java:1592)
  at javax.imageio.ImageIO.write(ImageIO.java:1520)
  at Compression.main(Compression.java:17)
  </code></pre>
  
  <p>Here is the code I'm currently using:</p>
  
  <pre><code>File input = new File("testEmily.jpeg");
      BufferedImage image = ImageIO.read(input);
      byte[] byteArray = RunLength.toByteArrayAutoClosable(image, "jpeg");
      byte[] compressedBytes2 = RunLength.compress(byteArray);
      ByteArrayInputStream bis = new ByteArrayInputStream(compressedBytes2);
      BufferedImage bImage2 = ImageIO.read(bis);
      ImageIO.write(bImage2, "jpeg", new File("compressedEmily.jpeg") );
  </code></pre>
  
  <p>Also this is github repo link if someone wants to reproduce - <a href="https://gitlab.com/Avivi/boniekrunlength" rel="nofollow noreferrer">https://gitlab.com/Avivi/boniekrunlength</a></p>