code: public static HashMap<String, Integer> getImageInfo(ImageInputStream input) {
          HashMap<String, Integer> map = new HashMap<String, Integer>(2);
  
          BufferedImage buff = null;
          try {
              buff = ImageIO.read(input);
              map.put("width", buff.getWidth());
              map.put("height", buff.getHeight());
              return map;
          } catch (IOException e) {
              e.printStackTrace();
          } catch (Exception e) {
              e.printStackTrace();
          }
  
          return null;
      }
docs: this function will not close input, need caller to close it.