code: public static BufferedImage getImage(InputStream input) throws IOException
      {
          final BufferedImage buffer = ImageIO.read(input);
          if (buffer == null)
          {
              throw new IOException("Invalid image !");
          }
          return copyImage(buffer);
      }
docs: Get an image from an input stream.
  
  @param input The image input stream.
  @return The loaded image.
  @throws IOException If error when reading image.