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...")
 
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.
  
 
== Parameters ==
 
== Parameters ==
 +
* '''Image Path:''' The path to the image where the text will be added. 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) Specifies the alignment of the text in 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. 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. This must be a valid font name.
  
'''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. 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. 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. Default is True.
  
'''Show Background Box:''' (Optional, default: true) Whether or not to display a background box behind the text.
+
== Example ==
  
'''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 ==
 
 
<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.

Revision as of 02:13, 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.

Parameters

  • Image Path: The path to the image where the text will be added. 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) Specifies the alignment of the text in 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. Default for all is 20.
  • Font Name: (optional) Specifies the font of the text. This must be a valid font name.
  • 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. 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.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox