code: private static byte[] createImageThumbnail(final InputStream is, final Dimension scaledSize) {
  		BufferedImage image;
  		MemoryCacheImageInputStream mciis;
  
  		try {
  			mciis = new MemoryCacheImageInputStream(is);
  			image = ImageIO.read(mciis);
  		} catch (Exception e) {
  			LOG.warn("Unable to read input image", e);
  			return null;
  		}
  
  		if (image == null) {
  			return null;
  		}
  
  		try {
  			byte[] jpeg = createScaledJPEG(image, scaledSize);
  			return jpeg;
  		} catch (Exception e) {
  			LOG.error("Error creating thumbnail from image", e);
  		} finally {
  			image.flush();
  		}
  
  		return null;
  
  	}
docs: This method will create a JPEG "thumb nail" of an image read from an {@link InputStream}. The maximum Dimension
  of the returned JPEG Image will be {@link #THUMBNAIL_MAX}.
  
  @param is the InputStream representing the image for which the JPEG thumb nail is to be returned.
  @param scaledSize the size to which the given <em>image</em> is to be scaled.
  @return a byte[] representing the JPEG thumb nail.