/** * Check whether any resize or crop param has been set. * * @return */ default boolean hasResizeParams() { return getHeight() != null || getWidth() != null || getCropMode() != null; }
/** * Generate cache key. * * @return */ default String getCacheKey() { StringBuilder builder = new StringBuilder(); if (getRect() != null) { builder.append("rect" + getRect().toString()); } if (getCropMode() != null) { builder.append("crop" + getCropMode()); } if (getWidth() != null) { builder.append("rw" + getWidth()); } if (getHeight() != null) { builder.append("rh" + getHeight()); } if (getFocalPoint() != null) { builder.append("fp" + getFocalPoint().toString()); } if (getFocalPointDebug()) { builder.append("fpdebug"); } if (getFocalPointZoom() != null) { builder.append("fpz" + getFocalPointZoom()); } return builder.toString(); }
/** * Resize the given image with the specified manipulation parameters. * * @param image The image to process * @param parameters The parameters defining cropping and resizing requests * @return The modified image */ private BufferedImage cropAndResize(BufferedImage image, ImageManipulationParameters parameters) { CropMode cropMode = parameters.getCropMode(); boolean omitResize = false; if (cropMode != null) { switch (cropMode) { case RECT: image = crop(image, parameters.getRect()); break; case FOCALPOINT: image = focalPointModifier.apply(image, parameters); // We don't need to resize the image again. The dimensions already match up with the target dimension omitResize = true; break; } } if (!omitResize) { image = resizeIfRequested(image, parameters); } return image; }