protected void storeImage(MasterImageMetaData mimd, MultipartFile mpFile) {
    try {
      InputStream imageStream = mpFile.getInputStream();
      log.debug("storeImage: uploaded a multipart file -- filename: " + FILE_UPLOAD_FIELD);

      ImageData imageData = imageResizeMgr.generateImage(imageStream, null, null);
      log.debug("storeImage: file name is: " + mpFile.getOriginalFilename());
      imageData.setFilename(mpFile.getOriginalFilename());

      // Store the image in the cache
      String imageKey = imageCacheManager.addImage(imageData);

      // Uploading a new image
      if (imageKey != mimd.getImageKey()) {
        // Then clear out the previous sized images and their data
        mimd.clearSizedImages();
      }

      // Add the image key and data to the Master Image
      mimd.setImageKey(imageKey);
      mimd.setMetaData(imageData);
    } catch (Exception e) {
      log.debug(
          "storeImage: An exception was caught in storeImage: No inputStream found because no file was uploaded.",
          e.fillInStackTrace());
    }
  }
 protected void resizeSimpleImage(
     SimpleImageMetaData image, String imageKey, Rectangle cropBox, Dimension size)
     throws Exception {
   ImageData imageData = imageCacheManager.getImage(imageKey);
   InputStream is = new ByteArrayInputStream(imageData.getBinary());
   ImageData imd = imageResizeMgr.generateImage(is, cropBox, size);
   String sizedKey = imageCacheManager.addImage(imd);
   image.setImageKey(sizedKey);
   image.setHeight(imd.getHeight());
   image.setWidth(imd.getWidth());
   image.setMetaData(imd);
 }