code: @Override
  	protected byte[] getData(Attributes attributes) {
          byte[] data = storageService.getLogoImage();
          if (!scale) {
          	return data;
          }
          
  		try {
  			InputStream is = new ByteArrayInputStream(data);
  			BufferedImage originalImage = ImageIO.read(is);						
  			int width = IMG_WIDTH; 
  			if (originalImage.getWidth() < IMG_WIDTH) {
  				width = originalImage.getWidth();
  			}
  			int height = IMG_HEIGHT;
  			if (originalImage.getHeight() < IMG_HEIGHT) {
  				height = originalImage.getHeight();
  			}
  			BufferedImage scaledImage = scaleImage(originalImage, width, height);
  			ByteArrayOutputStream os = new ByteArrayOutputStream();
  			ImageIO.write(scaledImage, "png", os);
  			
  			return os.toByteArray();
  		} catch (IOException e) {
  			e.printStackTrace();
  			return null;
  		}
      }
docs: /*
  public int getWidth() {
  try {
  BufferedImage originalImage = ImageIO.read(getResourceStream().getInputStream());
  return originalImage.getWidth();
  } catch (Exception e) {
  e.printStackTrace();
  return -1;
  }
  }
  
  public int getHeight() {
  try {
  
  BufferedImage originalImage = ImageIO.read(getResourceStream().getInputStream());
  return originalImage.getHeight();
  } catch (Exception e) {
  e.printStackTrace();
  return -1;
  }
  }