Overlay a logo and corresponding text onto a set of images Python Script
$0+
$0+
https://schema.org/InStock
usd
LearnGPT.today
The provided Python script is designed to overlay a logo and corresponding text onto a set of images using parameters and settings specified in a configuration file. It takes as input a directory containing images, an Excel file with two columns (image names and text), and a configuration file (settings.json) that defines various parameters like font, font size, font color, text margin, logo path, and logo margin. The script processes each image, adding the specified text and logo, and then saves the modified images to an output directory.
Usage Instructions:
1. Prerequisites:
- Python 3.x installed.
- Required Python libraries: Pillow (PIL), openpyxl.
2. Organize Your Files:
- Place the script (
main.py
) in the same directory as your images. - Create a directory called "output" where the modified images will be saved.
- Prepare an Excel file (
source.xlsx
) with two columns: Image Name and Text. This file should also be in the same directory.
3. Configure Settings:
- Open the
settings.json
file and specify the following settings:-
"font_path"
: Path to the TrueType font file (e.g., "Roboto-Regular.ttf"). -
"font_size"
: Font size for the text (e.g., 36). -
"font_color"
: RGB color code for the font color as an array (e.g., [255, 255, 255] for white). -
"text_margin"
: Margin for the text from the bottom of the image (e.g., 20). -
"logo_path"
: Path to the logo image (e.g., "logo.png"). -
"logo_margin"
: Margin for the logo from the top-left corner of the image as an object with "left" and "top" properties (e.g., {"left": 20, "top": 20}).
-
4. Run the Script:
- Open a terminal/command prompt.
- Navigate to the directory containing the script and files.
- Execute the script by running the following command:
python main.py
5. Review Output:
- After running the script, the modified images will be saved in the "output" directory.
6. Adjust Settings (Optional):
- If the text appears too close to the bottom of the images, you can adjust the
"text_margin"
setting in thesettings.json
file and rerun the script as needed.
7. Repeat as Necessary:
- You can use this script to process multiple sets of images by creating different Excel files with image names and text and configuring separate
settings.json
files for each set.
That's it! You've successfully used the script to overlay text and logos on your images based on the specified settings.
Please make sure to replace the example file names and paths with your actual file names and paths in the instructions.
Size
16.2 MB
Add to wishlist