Class ImageTransformerScaleToArea
java.lang.Object
one.jpro.platform.image.manager.transformer.ImageTransformerScaleToArea
- All Implemented Interfaces:
JsonConvertible,ImageTransformer
This class implements an image transformer that scales images to a target area
while preserving the original aspect ratio.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionImageTransformerScaleToArea(int targetArea) Constructs an instance with the specified target area.ImageTransformerScaleToArea(int targetWidth, int targetHeight) Constructs an instance with a specified target width and height. -
Method Summary
Modifier and TypeMethodDescriptionorg.json.JSONObjecttoJSON()Converts the object to a JSON representation.transform(BufferedImage image) Transforms the given image, scaling it to the desired area while maintaining its original aspect ratio.
-
Constructor Details
-
ImageTransformerScaleToArea
public ImageTransformerScaleToArea(int targetArea) Constructs an instance with the specified target area.- Parameters:
targetArea- The desired area (in pixels) of the scaled image.- Throws:
IllegalArgumentException- if targetArea is not positive.
-
ImageTransformerScaleToArea
public ImageTransformerScaleToArea(int targetWidth, int targetHeight) Constructs an instance with a specified target width and height. The target area will be calculated as the product of targetWidth and targetHeight.- Parameters:
targetWidth- The desired width of the scaled image.targetHeight- The desired height of the scaled image.
-
-
Method Details
-
transform
Transforms the given image, scaling it to the desired area while maintaining its original aspect ratio.- Specified by:
transformin interfaceImageTransformer- Parameters:
image- The original image to be transformed.- Returns:
- The scaled image with the target area.
-
toJSON
public org.json.JSONObject toJSON()Description copied from interface:JsonConvertibleConverts the object to a JSON representation.- Specified by:
toJSONin interfaceJsonConvertible- Returns:
- A JSONObject representing the object.
-