Fit text to image

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
(Created page with "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, backgroun...")
 
(Parameters)
 
(4 intermediate revisions by one user not shown)
Line 1: Line 1:
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.
+
'''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 ==
 
== 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.
  
'''Image Path:''' The location of the original image to which you will apply modifications.
+
'''Text:''' The text that will be added to the image.
  
'''Text:''' The text to 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.
  
'''Output Path:''' The save location of the image after modifications.
+
'''Alignment:''' (Optional) Where the text will be positioned within the image. Can be "Top", "Bottom", or "Center". Default is "Bottom".
  
'''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.
  
'''Max Height:''' (Optional) The maximum height for the text. If not provided, the text height will adjust automatically.
+
'''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.
  
'''Top Margin:''' (Optional, default: 20) The margin between the top of the image and 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.
  
'''Bottom Margin:''' (Optional, default: 20) The margin between the bottom of the image and the text.
+
'''Font Color:''' (Optional) Specifies the color of the font. This can be the common name for a color, or its hex code (like #FFFFFF). Default is white.
  
'''Left Margin:''' (Optional, default: 20) The margin between the left side of the image and the text.
+
'''Show Background Box:''' (optional) Determines whether a background box for the text will be shown. The default is True.
  
'''Right Margin:''' (Optional, default: 20) The margin between the right side of the image and the text.
+
'''Box Color:''' (Optional) Specifies the color of the background box. This can be the common name for a color, or its hex code (like #FFFFFF). Default is black.
  
'''Font Name:''' (Optional) Name of the font to be used. If not specified, a default font is used.
+
'''Box Alpha:''' (Optional) Determines the transparency level of the background box; 0 is fully transparent, 100 is fully opaque. Default is 50.
  
'''Font Color:''' (Optional, default: White) The color of the text.
+
'''Should Wrap Text:''' (Optional) Determines if the text should wrap to a new line when it reaches the edge of the image.
  
'''Show Background Box:''' (Optional, default: true) Whether or not to display a background box behind the text.
+
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.
  
'''Box Color:''' (Optional, default: Black) The color of the background box.
+
If this value is set to False, the text will fit on one line, resized so that all the text fits within the image.
  
'''Box Alpha:''' (Optional, default: 50) The transparency of the background box on a scale of 0 (completely transparent) to 255 (completely opaque).
+
Default is True.
 
+
'''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 ==
 
== Example ==
 +
 
<pre>
 
<pre>
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)
+
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)
 
</pre>
 
</pre>
  
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.
+
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.

Latest revision as of 02:52, 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.

[edit] 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. This can be the common name for a color, or its hex code (like #FFFFFF). 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. This can be the common name for a color, or its hex code (like #FFFFFF). 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.

[edit] 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.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox