Class ImageTransformerFitWidth
java.lang.Object
one.jpro.platform.image.manager.transformer.ImageTransformerFitWidth
- All Implemented Interfaces:
JsonConvertible,ImageTransformer
This class is responsible for transforming images such that they fit a specified width,
maintaining the original image's aspect ratio.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionImageTransformerFitWidth(int targetWidth) Constructs an instance that sets the target width for the transformation.ImageTransformerFitWidth(int targetWidth, int devicePixelRatio) Constructs an instance that sets the target width based on a device pixel ratio. -
Method Summary
Modifier and TypeMethodDescriptionorg.json.JSONObjecttoJSON()Converts the object to a JSON representation.transform(BufferedImage inputImage) Transforms the input image to fit the specified target width while maintaining its original aspect ratio.
-
Constructor Details
-
ImageTransformerFitWidth
public ImageTransformerFitWidth(int targetWidth) Constructs an instance that sets the target width for the transformation.- Parameters:
targetWidth- The desired width of the output image.
-
ImageTransformerFitWidth
public ImageTransformerFitWidth(int targetWidth, int devicePixelRatio) Constructs an instance that sets the target width based on a device pixel ratio. This is useful for devices with different screen densities.- Parameters:
targetWidth- The base width of the desired output image.devicePixelRatio- The pixel ratio of the target device.
-
-
Method Details
-
transform
Transforms the input image to fit the specified target width while maintaining its original aspect ratio.- Specified by:
transformin interfaceImageTransformer- Parameters:
inputImage- The input BufferedImage to be transformed.- Returns:
- The transformed BufferedImage that fits the specified target width.
-
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.
-