Without marketing, no one sees you.
Without branding, no one trusts you.
Your business needs both.
Python script to create the featured image
Python script filename: C:\PythonPrograms\create_image\create_image_11.py
# create_image_11.py script_start
from PIL import Image, ImageDraw, ImageFont
# ————————————————–
# Load image
# ————————————————–
image_path = “c:/pythonprograms/create_image/skill_2_pex.jpg”
image = Image.open(image_path)
draw = ImageDraw.Draw(image)
# ————————————————–
# Fonts
# ————————————————–
try:
font_title = ImageFont.truetype(“calibri.ttf”, 105)
font_subtitle = ImageFont.truetype(“calibri.ttf”, 80)
except IOError:
font_title = ImageFont.load_default()
font_subtitle = ImageFont.load_default()
# ————————————————–
# Text
# ————————————————–
title_text_lines = [
“MARKETING AND BRANDING”,
“Without marketing, no one sees you.”,
“Without branding, no one trusts you.”,
“Your business needs both.”,
]
bottom_text = [
#(“ΝΟΜΟΣ”, 1020),
(“MINDSTORM.GR”, 1080),
]
# ————————————————–
# Layout tuning
# ————————————————–
center_x = image.width // 2
start_y = 210
first_line_spacing = 280
subtitle_spacing = 12
background_padding = 20
shadow_offset = (2, 2)
shadow_color = “black”
# ————————————————–
# Draw title block (OPTICAL CENTERING)
# ————————————————–
y = start_y
for i, line in enumerate(title_text_lines):
bbox = draw.textbbox((0, 0), line, font=font_title)
text_w = bbox[2] – bbox[0]
text_h = bbox[3] – bbox[1]
# White background only for first line
if i == 0:
draw.rectangle(
(
center_x – text_w // 2 – background_padding,
y – background_padding,
center_x + text_w // 2 + background_padding,
y + text_h + background_padding
),
fill=”white”
)
# Shadow
draw.text(
(center_x + shadow_offset[0], y + shadow_offset[1]),
line,
font=font_title,
fill=shadow_color,
anchor=”ma” # middle horizontally
)
# Main text
draw.text(
(center_x, y),
line,
font=font_title,
fill=”black” if i == 0 else “white”,
anchor=”ma”
)
# Vertical spacing
if i == 0:
y += text_h + first_line_spacing
else:
y += text_h + subtitle_spacing
# ————————————————–
# Bottom text
# ————————————————–
for text, y in bottom_text:
draw.text(
(center_x + 2, y + 2),
text,
font=font_subtitle,
fill=”black”,
anchor=”ma”
)
draw.text(
(center_x, y),
text,
font=font_subtitle,
fill=”white”,
anchor=”ma”
)
# ————————————————–
# Save
# ————————————————–
output_path = “c:/pythonprograms/create_image/skill_2_pex_with_text_linkedin.png”
image.save(output_path)
#script_end
Views: 0

Comments are closed.