public class AutoCropAndResize extends AbstractCropAndResize
AbstractCropAndResize
implementation which will resize to the configured targetWidth and
targetHeight, and crop if needed: while respecting the ratio of the target dimensions, it will crop
the image such that the largest possible portion of the image is kept. It will keep the central part
of the image and cut off the external parts (i.e centered crop).
If either targetWidth or targetHeight is <=0, the ratio of the source image will be preserved. If both targetWidth and targetHeight are >0, both will be used, even if they don't match the ratio of the source image (thus cropping it).
Constructor and Description |
---|
AutoCropAndResize() |
Modifier and Type | Method and Description |
---|---|
protected Coords |
getCroopCoords(BufferedImage source,
ParameterProvider params)
Determines the coordinates of the cropping to apply on the source image.
|
protected Size |
getEffectiveTargetSize(BufferedImage source,
Coords cropCoords,
ParameterProvider params)
Determines the actual size for the resized image based on the source image, the crop coordinates
calculated by
AbstractCropAndResize.getCroopCoords(java.awt.image.BufferedImage, P) and the given ParameterProvider. |
int |
getTargetHeight() |
int |
getTargetWidth() |
void |
setTargetHeight(int targetHeight) |
void |
setTargetWidth(int targetWidth) |
apply, getResizer, resize, setResizer
protected Coords getCroopCoords(BufferedImage source, ParameterProvider params) throws ImagingException
AbstractCropAndResize
getCroopCoords
in class AbstractCropAndResize
ImagingException
protected Size getEffectiveTargetSize(BufferedImage source, Coords cropCoords, ParameterProvider params)
AbstractCropAndResize
AbstractCropAndResize.getCroopCoords(java.awt.image.BufferedImage, P)
and the given ParameterProvider.getEffectiveTargetSize
in class AbstractCropAndResize
public int getTargetWidth()
public void setTargetWidth(int targetWidth)
public int getTargetHeight()
public void setTargetHeight(int targetHeight)
Copyright © 2016 Magnolia International Ltd.. All rights reserved.