Generate logo on build

This commit is contained in:
strongtz 2021-01-17 03:49:18 +00:00 committed by BigfootACA
parent 5636e9a759
commit 25cf14bcb1
6 changed files with 47 additions and 0 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ uefi-*.img.gz-dtb
workspace
*.dll
ramdisk
sdm845Pkg/Drivers/LogoDxe/Logo.bmp

BIN
assets/Logo.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

BIN
assets/NotoSerif-Italic.ttf Normal file

Binary file not shown.

46
assets/generate-logo.py Normal file
View File

@ -0,0 +1,46 @@
#!/usr/bin/python3
import time
ohmydate = str(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
import sys
pwd = sys.path[0]
import PIL
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
from git import Repo
imageFile = pwd + "/Logo.bmp"
file_save_dir = pwd + "/../sdm845Pkg/Drivers/LogoDxe/"
outputName = "Logo"
print(ohmydate)
repoPath = pwd + "/.."
repo = Repo(repoPath)
gitHead = str(repo.head.commit)
print(gitHead)
strs = "head:" + gitHead + "\n Build:" + ohmydate
x = 1
y = 1
word_size = 11
word_css = pwd + "/NotoSerif-Italic.ttf"
#Set font
font = ImageFont.truetype(word_css,word_size)
im1=Image.open(imageFile)
draw = ImageDraw.Draw(im1)
print(font.getsize(strs))
draw.text((x, y),strs,(255,255,0),font=font)
new_filename = file_save_dir +outputName.replace(",","-").replace("\n","-")+".bmp"
im1.save(new_filename)
del draw
im1.close()

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 KiB

After

Width:  |  Height:  |  Size: 230 KiB