Class PromptImageGeometryConverters

java.lang.Object
de.xima.fc.prompt.service.support.PromptImageGeometryConverters

public final class PromptImageGeometryConverters extends Object
Factory for common IPromptImageGeometryConverter implementations.
Since:
8.5.0
  • Method Details

    • enlargeCanvasToAspectRatio

      public static IPromptImageGeometryConverter enlargeCanvasToAspectRatio(double newRatio)
      Changes the canvas size to the new aspect ratio, enlarging the image as needed to fill the canvas. The image size is never changed, and the image is placed in the center of the new canvas.
      Parameters:
      newRatio - The new aspect ratio (width / height).
      Returns:
      The resize strategy.
    • fixedSize

      public static IPromptImageGeometryConverter fixedSize(int newWidth, int newHeight)
      Resizes the image to the fixed size.
      Parameters:
      newWidth - The new width.
      newHeight - The new height.
      Returns:
      The resize strategy.
    • resizeCanvas

      public static IPromptImageGeometryConverter resizeCanvas(int newWidth, int newHeight, EPromptImageObjectFit objectFit)
      Resizes the canvas to the given dimensions, fitting the image using the specified object fit strategy.
      Parameters:
      newWidth - The new width.
      newHeight - The new height.
      objectFit - The object fit strategy.
      Returns:
      The resize strategy.
    • scale

      public static IPromptImageGeometryConverter scale(double scale)
      Scales the image by the given factor.
      Parameters:
      scale - The scale factor. E.g. 0.5 to reduce size by half, 2.0 to double size.
      Returns:
      The resize strategy.
    • stretchToAspectRatio

      public static IPromptImageGeometryConverter stretchToAspectRatio(double newRatio)
      Resizes the image to the new aspect ratio, stretching it either horizontally or vertically as needed. The image is always enlarged, never shrunk. The image always fills the entire canvas, there are no empty borders.
      Parameters:
      newRatio - The new aspect ratio (width / height).
      Returns:
      The resize strategy.