docs: public byte[] scaleImage(byte[] content, String rootPath) {
  
          byte[] result = content;
          // flag for processed image
          boolean imageProcessed = false;
          // initialize image crop area
          initCropArea();
  
          RenderSettings renderSettings;
          if ((m_renderMode == 0) && (m_quality == 0)) {
              // use default render mode and quality
              renderSettings = new RenderSettings(Simapi.RENDER_QUALITY);
          } else {
              // use special render mode and/or quality
              renderSettings = new RenderSettings(m_renderMode);
              if (m_quality != 0) {
                  renderSettings.setCompressionQuality(m_quality / 100f);
              }
          }
          // set max blur size
          renderSettings.setMaximumBlurSize(m_maxBlurSize);
          // new create the scaler
          Simapi scaler = new Simapi(renderSettings);
          // calculate a valid image type supported by the imaging library (e.g. "JPEG", "GIF")
          String imageType = Simapi.getImageType(rootPath);
          if (imageType == null) {
              // no type given, maybe the name got mixed up
              String mimeType = OpenCms.getResourceManager().getMimeType(rootPath, null, null);
              // check if this is another known MIME type, if so DONT use it (images should not be named *.pdf)
              if (mimeType == null) {
                  // no MIME type found, use JPEG format to write images to the cache
                  imageType = Simapi.TYPE_JPEG;
              }
          }
          if (imageType == null) {
              // unknown type, unable to scale the image
              if (LOG.isDebugEnabled()) {
                  LOG.debug(Messages.get().getBundle().key(Messages.ERR_UNABLE_TO_SCALE_IMAGE_2, rootPath, toString()));
              }
              return result;
          }
          try {
              BufferedImage image = Simapi.read(content);
  
              if (isCropping()) {
                  // check if the crop width / height are not larger then the source image
                  if ((getType() == 0) && ((m_cropHeight > image.getHeight()) || (m_cropWidth > image.getWidth()))) {
                      // crop height / width is outside of image - return image unchanged
                      return result;
                  }
              }
  
              Color color = getColor();
  
              if (!m_filters.isEmpty()) {
                  Iterator<String> i = m_filters.iterator();
                  while (i.hasNext()) {
                      String filter = i.next();
                      if (FILTER_GRAYSCALE.equals(filter)) {
                          // add a gray scale filter
                          GrayscaleFilter grayscaleFilter = new GrayscaleFilter();
                          renderSettings.addImageFilter(grayscaleFilter);
                      } else if (FILTER_SHADOW.equals(filter)) {
                          // add a drop shadow filter
                          ShadowFilter shadowFilter = new ShadowFilter();
                          shadowFilter.setXOffset(5);
                          shadowFilter.setYOffset(5);
                          shadowFilter.setOpacity(192);
                          shadowFilter.setBackgroundColor(color.getRGB());
                          color = Simapi.COLOR_TRANSPARENT;
                          renderSettings.setTransparentReplaceColor(Simapi.COLOR_TRANSPARENT);
                          renderSettings.addImageFilter(shadowFilter);
                      }
                  }
              }
  
              if (isCropping()) {
                  if ((getType() == 8) && (m_focalPoint != null)) {
                      image = scaler.cropToSize(
                          image,
                          m_cropX,
                          m_cropY,
                          m_cropWidth,
                          m_cropHeight,
                          m_cropWidth,
                          m_cropHeight,
                          color);
                      // Find the biggest scaling factor which, when applied to a rectangle of dimensions m_width x m_height,
                      // would allow the resulting rectangle to still fit inside a rectangle of dimensions m_cropWidth x m_cropHeight
                      // (we have to take the minimum because a rectangle that fits on the x axis might still be out of bounds on the y axis, and
                      // vice versa).
                      double scaling = Math.min((1.0 * m_cropWidth) / m_width, (1.0 * m_cropHeight) / m_height);
                      int relW = (int)(scaling * m_width);
                      int relH = (int)(scaling * m_height);
                      // the focal point's coordinates are in the uncropped image's coordinate system, so we have to subtract cx/cy
                      int relX = (int)(m_focalPoint.getX() - m_cropX);
                      int relY = (int)(m_focalPoint.getY() - m_cropY);
                      image = scaler.cropPointToSize(image, relX, relY, false, relW, relH);
                      if ((m_width != relW) || (m_height != relH)) {
                          image = scaler.scale(image, m_width, m_height);
                      }
                  } else if ((getType() == 6) || (getType() == 7)) {
                      // image crop operation around point
                      image = scaler.cropPointToSize(image, m_cropX, m_cropY, getType() == 6, m_cropWidth, m_cropHeight);
                  } else {
                      // image crop operation
                      image = scaler.cropToSize(
                          image,
                          m_cropX,
                          m_cropY,
                          m_cropWidth,
                          m_cropHeight,
                          getWidth(),
                          getHeight(),
                          color);
                  }
  
                  imageProcessed = true;
              } else {
                  // only rescale the image, if the width and height are different to the target size
                  int imageWidth = image.getWidth();
                  int imageHeight = image.getHeight();
  
                  // image rescale operation
                  switch (getType()) {
                      // select the "right" method of scaling according to the "t" parameter
                      case 1:
                          // thumbnail generation mode (like 0 but no image enlargement)
                          image = scaler.resize(image, getWidth(), getHeight(), color, getPosition(), false);
                          imageProcessed = true;
                          break;
                      case 2:
                          // scale to exact target size, crop what does not fit
                          if (((imageWidth != getWidth()) || (imageHeight != getHeight()))) {
                              image = scaler.resize(image, getWidth(), getHeight(), getPosition());
                              imageProcessed = true;
                          }
                          break;
                      case 3:
                          // scale and keep image proportions, target size variable
                          if (((imageWidth != getWidth()) || (imageHeight != getHeight()))) {
                              image = scaler.resize(image, getWidth(), getHeight(), true);
                              imageProcessed = true;
                          }
                          break;
                      case 4:
                          // don't keep image proportions, use exact target size
                          if (((imageWidth != getWidth()) || (imageHeight != getHeight()))) {
                              image = scaler.resize(image, getWidth(), getHeight(), false);
                              imageProcessed = true;
                          }
                          break;
                      case 5:
                          // scale and keep image proportions, target size variable, include maxWidth / maxHeight option
                          // image proportions have already been calculated so should not be a problem, use
                          // 'false' to make sure image size exactly matches height and width attributes of generated tag
                          if (((imageWidth != getWidth()) || (imageHeight != getHeight()))) {
                              image = scaler.resize(image, getWidth(), getHeight(), false);
                              imageProcessed = true;
                          }
                          break;
                      default:
                          // scale to exact target size with background padding
                          image = scaler.resize(image, getWidth(), getHeight(), color, getPosition(), true);
                          imageProcessed = true;
                  }
  
              }
  
              if (!m_filters.isEmpty()) {
                  Rectangle targetSize = scaler.applyFilterDimensions(getWidth(), getHeight());
                  image = scaler.resize(
                      image,
                      (int)targetSize.getWidth(),
                      (int)targetSize.getHeight(),
                      Simapi.COLOR_TRANSPARENT,
                      Simapi.POS_CENTER);
                  image = scaler.applyFilters(image);
                  imageProcessed = true;
              }
  
              // get the byte result for the scaled image if some changes have been made.
              // otherwiese use the original image
              if (imageProcessed) {
                  result = scaler.getBytes(image, imageType);
              }
          } catch (Exception e) {
              if (LOG.isDebugEnabled()) {
                  LOG.debug(
                      Messages.get().getBundle().key(Messages.ERR_UNABLE_TO_SCALE_IMAGE_2, rootPath, toString()),
                      e);
              }
          }
          return result;
      }