mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-03 11:14:59 +00:00
style: Format code with linter
This commit is contained in:
parent
efa36a7196
commit
42363beb72
1 changed files with 22 additions and 15 deletions
|
@ -1,6 +1,6 @@
|
||||||
|
import os
|
||||||
|
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
import os
|
|
||||||
|
|
||||||
# --- Configuration ---
|
# --- Configuration ---
|
||||||
WIDTH = 1200 # Twitter card image width
|
WIDTH = 1200 # Twitter card image width
|
||||||
|
@ -33,6 +33,7 @@ FONT_PATHS_REGULAR = [
|
||||||
"arial.ttf",
|
"arial.ttf",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# --- Helper Function to Find Font ---
|
# --- Helper Function to Find Font ---
|
||||||
def find_font(font_paths, default_size):
|
def find_font(font_paths, default_size):
|
||||||
for path in font_paths:
|
for path in font_paths:
|
||||||
|
@ -44,19 +45,23 @@ def find_font(font_paths, default_size):
|
||||||
# Pillow's default font doesn't support sizing well, return None to handle later
|
# Pillow's default font doesn't support sizing well, return None to handle later
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
# --- Load Fonts ---
|
# --- Load Fonts ---
|
||||||
font_large = find_font(FONT_PATHS_BOLD, FONT_SIZE_LARGE)
|
font_large = find_font(FONT_PATHS_BOLD, FONT_SIZE_LARGE)
|
||||||
font_medium = find_font(FONT_PATHS_BOLD, FONT_SIZE_MEDIUM)
|
font_medium = find_font(FONT_PATHS_BOLD, FONT_SIZE_MEDIUM)
|
||||||
font_small = find_font(FONT_PATHS_REGULAR, FONT_SIZE_SMALL)
|
font_small = find_font(FONT_PATHS_REGULAR, FONT_SIZE_SMALL)
|
||||||
|
|
||||||
# Use Pillow's basic default only if absolutely necessary (will look bad)
|
# Use Pillow's basic default only if absolutely necessary (will look bad)
|
||||||
if not font_large: font_large = ImageFont.load_default()
|
if not font_large:
|
||||||
if not font_medium: font_medium = ImageFont.load_default()
|
font_large = ImageFont.load_default()
|
||||||
if not font_small: font_small = ImageFont.load_default()
|
if not font_medium:
|
||||||
|
font_medium = ImageFont.load_default()
|
||||||
|
if not font_small:
|
||||||
|
font_small = ImageFont.load_default()
|
||||||
|
|
||||||
|
|
||||||
# --- Create Base Image ---
|
# --- Create Base Image ---
|
||||||
image = Image.new('RGB', (WIDTH, HEIGHT), color=BG_COLOR)
|
image = Image.new("RGB", (WIDTH, HEIGHT), color=BG_COLOR)
|
||||||
draw = ImageDraw.Draw(image)
|
draw = ImageDraw.Draw(image)
|
||||||
|
|
||||||
# --- Load and Place Logo (Optional) ---
|
# --- Load and Place Logo (Optional) ---
|
||||||
|
@ -76,7 +81,7 @@ try:
|
||||||
logo_height = logo_img.height
|
logo_height = logo_img.height
|
||||||
logo_x = (WIDTH - logo_img.width) // 2
|
logo_x = (WIDTH - logo_img.width) // 2
|
||||||
# Paste logo, handling transparency if PNG has alpha channel
|
# Paste logo, handling transparency if PNG has alpha channel
|
||||||
if logo_img.mode == 'RGBA':
|
if logo_img.mode == "RGBA":
|
||||||
image.paste(logo_img, (logo_x, int(logo_y_pos)), logo_img)
|
image.paste(logo_img, (logo_x, int(logo_y_pos)), logo_img)
|
||||||
else:
|
else:
|
||||||
image.paste(logo_img, (logo_x, int(logo_y_pos)))
|
image.paste(logo_img, (logo_x, int(logo_y_pos)))
|
||||||
|
@ -113,7 +118,9 @@ draw.text((center_x, current_y), line3, fill=TEXT_COLOR, font=font_medium, ancho
|
||||||
current_y += FONT_SIZE_MEDIUM + 60
|
current_y += FONT_SIZE_MEDIUM + 60
|
||||||
|
|
||||||
# Line 4: Repo URL (smaller at bottom)
|
# Line 4: Repo URL (smaller at bottom)
|
||||||
draw.text((center_x, HEIGHT - FONT_SIZE_SMALL - 30), line4, fill=TEXT_COLOR, font=font_small, anchor="mb")
|
draw.text(
|
||||||
|
(center_x, HEIGHT - FONT_SIZE_SMALL - 30), line4, fill=TEXT_COLOR, font=font_small, anchor="mb"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# --- Save Image ---
|
# --- Save Image ---
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue