Class ImageTransformerFitWidth

java.lang.Object
one.jpro.platform.image.manager.transformer.ImageTransformerFitWidth
All Implemented Interfaces:
JsonConvertible, ImageTransformer

public class ImageTransformerFitWidth extends Object implements 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 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

      public BufferedImage transform(BufferedImage inputImage)
      Transforms the input image to fit the specified target width while maintaining its original aspect ratio.
      Specified by:
      transform in interface ImageTransformer
      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: JsonConvertible
      Converts the object to a JSON representation.
      Specified by:
      toJSON in interface JsonConvertible
      Returns:
      A JSONObject representing the object.