Fit text to image
(→Parameters) |
(→Parameters) |
||
Line 4: | Line 4: | ||
== Parameters == | == Parameters == | ||
− | '''Image Path:''' The path to the image | + | '''Image Path:''' The path to the image that the text will be added to. This must be a valid file path on the system where the script is running. |
'''Text:''' The text that will be added to the image. | '''Text:''' The text that will be added to the image. | ||
Line 10: | Line 10: | ||
'''Output Path:''' The path where the modified image will be saved. This must be a valid location on the system where the script is running. | '''Output Path:''' The path where the modified image will be saved. This must be a valid location on the system where the script is running. | ||
− | '''Alignment:''' (Optional) | + | '''Alignment:''' (Optional) Where the text will be positioned within the image. Can be "Top", "Bottom", or "Center". Default is "Bottom". |
'''Max Height:''' (Optional) The maximum height for the text. | '''Max Height:''' (Optional) The maximum height for the text. | ||
− | '''Top/Bottom/Left/Right Margin:''' (Optional) Specifies the top, bottom, left, and right margins for the text. Default for all is 20. | + | '''Top/Bottom/Left/Right Margin:''' (Optional) Specifies the top, bottom, left, and right margins for the text. Use these along with '''Alignment''' for precise positioning of the text. Default for all is 20. |
− | '''Font Name:''' (Optional) Specifies the font of the text. | + | '''Font Name:''' (Optional) Specifies the font of the text. Options include system fonts and Google Fonts. In addition to the fonts in the drop down, you can enter the name of any Google Font. If a Google Font is entered, it will be dynamically downloaded when the script is run. |
'''Font Color:''' (Optional) Specifies the color of the font. Default is white. | '''Font Color:''' (Optional) Specifies the color of the font. Default is white. | ||
Line 26: | Line 26: | ||
'''Box Alpha:''' (Optional) Determines the transparency level of the background box; 0 is fully transparent, 100 is fully opaque. Default is 50. | '''Box Alpha:''' (Optional) Determines the transparency level of the background box; 0 is fully transparent, 100 is fully opaque. Default is 50. | ||
− | '''Should Wrap Text:''' (Optional) Determines if the text should wrap to a new line when it reaches the edge of the image. Default is True. | + | '''Should Wrap Text:''' (Optional) Determines if the text should wrap to a new line when it reaches the edge of the image. |
+ | |||
+ | If this value is set to True, the text will fit on multiple lines in a way that best maximizes the space defined by the alignment and borders. | ||
+ | |||
+ | If this value is set to False, the text will fit on one line, resized so that all the text fits within the image. | ||
+ | |||
+ | Default is True. | ||
== Example == | == Example == |
Revision as of 02:49, 4 July 2023
fit text to image is a command that adds text to an image with multiple customizable settings such as alignment, margins, font and background box. After modifications, the image is saved to a specified path.
This is a powerful command that you can use to create memes, thumbnails, comic, and any other graphic/text combinations.
Parameters
Image Path: The path to the image that the text will be added to. This must be a valid file path on the system where the script is running.
Text: The text that will be added to the image.
Output Path: The path where the modified image will be saved. This must be a valid location on the system where the script is running.
Alignment: (Optional) Where the text will be positioned within the image. Can be "Top", "Bottom", or "Center". Default is "Bottom".
Max Height: (Optional) The maximum height for the text.
Top/Bottom/Left/Right Margin: (Optional) Specifies the top, bottom, left, and right margins for the text. Use these along with Alignment for precise positioning of the text. Default for all is 20.
Font Name: (Optional) Specifies the font of the text. Options include system fonts and Google Fonts. In addition to the fonts in the drop down, you can enter the name of any Google Font. If a Google Font is entered, it will be dynamically downloaded when the script is run.
Font Color: (Optional) Specifies the color of the font. Default is white.
Show Background Box: (optional) Determines whether a background box for the text will be shown. The default is True.
Box Color: (Optional) Specifies the color of the background box. Default is black.
Box Alpha: (Optional) Determines the transparency level of the background box; 0 is fully transparent, 100 is fully opaque. Default is 50.
Should Wrap Text: (Optional) Determines if the text should wrap to a new line when it reaches the edge of the image.
If this value is set to True, the text will fit on multiple lines in a way that best maximizes the space defined by the alignment and borders.
If this value is set to False, the text will fit on one line, resized so that all the text fits within the image.
Default is True.
Example
fit text to image("image path.jpg", "This is the text to be added.", "output path.jpg", "Center", 40, 20, 10, 30, 10, "Comic Sans MS", "blue", True, "grey", 80, True)
The output will be a saved image at "output path.jpg", with the text "This is the text to be added." placed in the center of the image with a grey background box. The text would be in Comic Sans MS font with a blue color and margins as specified. When the text reaches the right or left margin, it will wrap to the next line.