Fit text to image
The fit text to image command adds custom text to an image. The addition is customizable, allowing the adjustments to the alignment, margins, font, font color, background box and its parameters. When all modifications are added, the image is then saved to a specified path.
Parameters
Image Path: The location of the original image to which you will apply modifications.
Text: The text to be added to the image.
Output Path: The save location of the image after modifications.
Alignment: (Optional, default: Bottom) The position of the text within the image. Choices include Top, Bottom and Center.
Max Height: (Optional) The maximum height for the text. If not provided, the text height will adjust automatically.
Top Margin: (Optional, default: 20) The margin between the top of the image and the text.
Bottom Margin: (Optional, default: 20) The margin between the bottom of the image and the text.
Left Margin: (Optional, default: 20) The margin between the left side of the image and the text.
Right Margin: (Optional, default: 20) The margin between the right side of the image and the text.
Font Name: (Optional) Name of the font to be used. If not specified, a default font is used.
Font Color: (Optional, default: White) The color of the text.
Show Background Box: (Optional, default: true) Whether or not to display a background box behind the text.
Box Color: (Optional, default: Black) The color of the background box.
Box Alpha: (Optional, default: 50) The transparency of the background box on a scale of 0 (completely transparent) to 255 (completely opaque).
Should Wrap Text: If true, wrap text to fit within the left and right margins. If false, include the text regardless of whether it crosses the margins.
Example
fit text to image("input.jpg", "Hello, world!", "output.jpg", Top, 80, Top: 20, Bottom: 20, Left: 20, Right: 20, Arial, Black, true, Black, 120, true)
The script above adds the text "Hello, world!" to the top of the image in "input.jpg" using the Arial font in black, with a semi-transparent black background box, and saves the result to "output.jpg". The text should wrap within the margins if it is too long to fit on one line. The image is padded with a 20-pixel margin around all edges.