Class ImageTransformerFitHeight

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

public class ImageTransformerFitHeight extends Object implements ImageTransformer
This class is responsible for transforming images such that they fit a specified height, while maintaining their original aspect ratio.
See Also:
  • 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

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