Class ImageTransformerFitHeight
java.lang.Object
one.jpro.platform.image.manager.transformer.ImageTransformerFitHeight
- All Implemented Interfaces:
JsonConvertible,ImageTransformer
This class is responsible for transforming images such that they fit a specified height,
while maintaining their original aspect ratio.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionImageTransformerFitHeight(int targetHeight) Constructs an instance with a specified target height.ImageTransformerFitHeight(int targetHeight, int devicePixelRatio) Constructs an instance with a specified target height and device pixel ratio. -
Method Summary
Modifier and TypeMethodDescriptionorg.json.JSONObjecttoJSON()Converts the object to a JSON representation.transform(BufferedImage original) Transforms (resizes) the given image to have the target height while maintaining its original aspect ratio.
-
Constructor Details
-
ImageTransformerFitHeight
public ImageTransformerFitHeight(int targetHeight) Constructs an instance with a specified target height.- Parameters:
targetHeight- The target height in pixels for the resulting image.
-
ImageTransformerFitHeight
public ImageTransformerFitHeight(int targetHeight, int devicePixelRatio) Constructs an instance with a specified target height and device pixel ratio. This constructor adjusts the target height based on the provided device pixel ratio.- Parameters:
targetHeight- The original target height in pixels.devicePixelRatio- The device pixel ratio to adjust the height.
-
-
Method Details
-
transform
Transforms (resizes) the given image to have the target height while maintaining its original aspect ratio.- Specified by:
transformin interfaceImageTransformer- Parameters:
original- The original BufferedImage to be transformed.- Returns:
- A new BufferedImage that has been resized to the target height.
-
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.
-