-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PostBot: Initial integration of banner generation [skip ci]
Change-Id: I80d9386908bb9f3724c6bf4a1f475a324777f822 Signed-off-by: PrajjuS <[email protected]>
- Loading branch information
Showing
7 changed files
with
27 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import os | ||
from PIL import Image, ImageDraw, ImageFont | ||
|
||
TEMPLATE_PATH = "./assets/banners/template.png" | ||
FONT_PATH = "./assets/fonts" | ||
|
||
def generate_banner(device_vendor: str, device_name: str, device_codename: str): | ||
template = Image.open(TEMPLATE_PATH) | ||
draw = ImageDraw.Draw(template) | ||
|
||
font_vendor = ImageFont.truetype(f"{FONT_PATH}/GENERALSANS-MEDIUM.OTF", size=60) | ||
font_device = ImageFont.truetype(f"{FONT_PATH}/GENERALSANS-MEDIUM.OTF", size=140 if len(device_name) <= 12 else 100) | ||
font_codename = ImageFont.truetype(f"{FONT_PATH}/CONFIG-MEDIUM.OTF", size=40) | ||
|
||
draw.text((85, 590), device_vendor, font=font_vendor, fill=(255, 69, 0)) | ||
draw.text((80, 680), device_name, font=font_device, fill=(238, 238, 238)) | ||
draw.text((80, 1320), device_codename.upper(), font=font_codename, fill=(51, 51, 51)) | ||
|
||
|
||
output_filename = f"./assets/{device_codename}_banner.png" | ||
template.save(output_filename) | ||
return os.path.abspath(output_filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.