Class PromptImageGeometryConverters
- java.lang.Object
-
- de.xima.fc.prompt.service.support.PromptImageGeometryConverters
-
public final class PromptImageGeometryConverters extends Object
Factory for commonIPromptImageGeometryConverterimplementations.- Since:
- 8.5.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static IPromptImageGeometryConverterenlargeCanvasToAspectRatio(double newRatio)Changes the canvas size to the new aspect ratio, enlarging the image as needed to fill the canvas.static IPromptImageGeometryConverterfixedSize(int newWidth, int newHeight)Resizes the image to the fixed size.static IPromptImageGeometryConverterresizeCanvas(int newWidth, int newHeight, EPromptImageObjectFit objectFit)Resizes the canvas to the given dimensions, fitting the image using the specified object fit strategy.static IPromptImageGeometryConverterscale(double scale)Scales the image by the given factor.static IPromptImageGeometryConverterstretchToAspectRatio(double newRatio)Resizes the image to the new aspect ratio, stretching it either horizontally or vertically as needed.
-
-
-
Method Detail
-
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.
-
-