Class PromptImageGeometryConverters
java.lang.Object
de.xima.fc.prompt.service.support.PromptImageGeometryConverters
Factory for common
IPromptImageGeometryConverter implementations.- Since:
- 8.5.0
-
Method Summary
Modifier and TypeMethodDescriptionenlargeCanvasToAspectRatio(double newRatio) Changes the canvas size to the new aspect ratio, enlarging the image as needed to fill the canvas.fixedSize(int newWidth, int newHeight) Resizes the image to the fixed size.resizeCanvas(int newWidth, int newHeight, EPromptImageObjectFit objectFit) Resizes the canvas to the given dimensions, fitting the image using the specified object fit strategy.scale(double scale) Scales the image by the given factor.stretchToAspectRatio(double newRatio) Resizes the image to the new aspect ratio, stretching it either horizontally or vertically as needed.
-
Method Details
-
enlargeCanvasToAspectRatio
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
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
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
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.
-