import sys, io
from PIL import Image, ImageDraw, ImageFont
path, colorname = sys.argv[1], sys.argv[2]
label, color, ink = ('BLUE v1', '#1261e8', 'white') if colorname == 'blue' else ('YELLOW v2', '#ffe100', 'black')
try: font = ImageFont.truetype('/usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf', 28)
except Exception: font = ImageFont.load_default(28)
im = Image.new('RGB', (360, 100), color); ImageDraw.Draw(im).text((12, 34), label, font=font, fill=ink)
buf = io.BytesIO(); im.save(buf, 'PNG'); data = buf.getvalue()
import os
mode = 'r+b' if os.path.exists(path) else 'wb'
with open(path, mode) as f:  # in place: same inode
    f.seek(0); f.write(data); f.truncate(); f.flush(); os.fsync(f.fileno())
print(path, colorname, os.stat(path).st_ino, len(data))
