Try building
This commit is contained in:
BIN
Nunito-ExtraLight.ttf
Normal file
BIN
Nunito-ExtraLight.ttf
Normal file
Binary file not shown.
BIN
Nunito-SemiBold.ttf
Normal file
BIN
Nunito-SemiBold.ttf
Normal file
Binary file not shown.
BIN
SymbolsNerdFont-Regular.ttf
Normal file
BIN
SymbolsNerdFont-Regular.ttf
Normal file
Binary file not shown.
48
building-out.py
Normal file
48
building-out.py
Normal file
@@ -0,0 +1,48 @@
|
||||
from PIL import Image
|
||||
from PIL import ImageDraw
|
||||
from PIL import ImageFont
|
||||
from datetime import datetime
|
||||
from time import gmtime, strftime
|
||||
import time
|
||||
|
||||
black = '#000000'
|
||||
white = '#ffffff'
|
||||
|
||||
image = Image.new("P", (400, 300))
|
||||
draw = ImageDraw.Draw(image)
|
||||
|
||||
fontSymbols = ImageFont.truetype("SymbolsNerdFont-Regular.ttf", 18)
|
||||
fontTitle = ImageFont.truetype("Nunito-SemiBold.ttf", 24)
|
||||
fontLarge = ImageFont.truetype ("Nunito-ExtraLight.ttf", 18)
|
||||
fontSmall = ImageFont.truetype ("Nunito-ExtraLight.ttf", 16)
|
||||
fontVerySmall = ImageFont.truetype("Nunito-ExtraLight.ttf", 10)
|
||||
|
||||
# Draw the top bar
|
||||
draw.rectangle((0, 0, 400, 300), fill=white)
|
||||
draw.rectangle((0, 0, 400, 40), fill=black)
|
||||
|
||||
# Add the clock
|
||||
timeStr = strftime("%H:%M", time.localtime())
|
||||
draw.text((10, 10), timeStr, white, fontSmall)
|
||||
|
||||
# Add indoor tempriture
|
||||
draw.text((350, 10), "19c", white, fontSmall)
|
||||
|
||||
# Add tasks
|
||||
draw.text((10, 50), 'Tasks', black, fontTitle)
|
||||
|
||||
draw.text((10, 90), '', black, fontSymbols)
|
||||
draw.text((30, 87), 'Do a thing', black, fontLarge)
|
||||
|
||||
|
||||
draw.text((10, 120), '', black, fontSymbols)
|
||||
draw.text((30, 117), 'Done a thing', black, fontLarge)
|
||||
|
||||
|
||||
# image.save('built.bmp')
|
||||
from inky import InkyWHAT
|
||||
from inky.auto import auto
|
||||
|
||||
display = auto(verbose = True)
|
||||
display.set_image(image)
|
||||
display.show()
|
||||
42
building.py
Normal file
42
building.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from PIL import Image
|
||||
from PIL import ImageDraw
|
||||
from PIL import ImageFont
|
||||
from datetime import datetime
|
||||
from time import gmtime, strftime
|
||||
import time
|
||||
|
||||
black = '#000000'
|
||||
white = '#ffffff'
|
||||
|
||||
image = Image.new("P", (400, 300))
|
||||
draw = ImageDraw.Draw(image)
|
||||
|
||||
fontSymbols = ImageFont.truetype("SymbolsNerdFont-Regular.ttf", 18)
|
||||
fontTitle = ImageFont.truetype("Nunito-SemiBold.ttf", 24)
|
||||
fontLarge = ImageFont.truetype ("Nunito-ExtraLight.ttf", 18)
|
||||
fontSmall = ImageFont.truetype ("Nunito-ExtraLight.ttf", 16)
|
||||
fontVerySmall = ImageFont.truetype("Nunito-ExtraLight.ttf", 10)
|
||||
|
||||
# Draw the top bar
|
||||
draw.rectangle((0, 0, 400, 300), fill=white)
|
||||
draw.rectangle((0, 0, 400, 40), fill=black)
|
||||
|
||||
# Add the clock
|
||||
timeStr = strftime("%H:%M", time.localtime())
|
||||
draw.text((10, 10), timeStr, white, fontSmall)
|
||||
|
||||
# Add indoor tempriture
|
||||
draw.text((350, 10), "19c", white, fontSmall)
|
||||
|
||||
# Add tasks
|
||||
draw.text((10, 50), 'Tasks', black, fontTitle)
|
||||
|
||||
draw.text((10, 90), '', black, fontSymbols)
|
||||
draw.text((30, 87), 'Do a thing', black, fontLarge)
|
||||
|
||||
|
||||
draw.text((10, 120), '', black, fontSymbols)
|
||||
draw.text((30, 117), 'Done a thing', black, fontLarge)
|
||||
|
||||
|
||||
image.save('built.bmp')
|
||||
@@ -6,13 +6,15 @@ from inky.auto import auto
|
||||
|
||||
display = auto(verbose = True)
|
||||
|
||||
# config = imgkit.config(wkhtmltoimage='C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltoimage.exe')
|
||||
config = imgkit.config(wkhtmltoimage='C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltoimage.exe')
|
||||
|
||||
print("Generating html...")
|
||||
|
||||
|
||||
print("Converting to image...")
|
||||
imgkit.from_file('./test.html', 'out.png', options={
|
||||
imgkit.from_file('./test.html', 'out.png',
|
||||
config=config,
|
||||
options={
|
||||
'format': 'png',
|
||||
'crop-h': '300',
|
||||
'crop-w': '400'
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<link rel="stylesheet" href="https://unpkg.com/tachyons/css/tachyons.min.css">
|
||||
|
||||
<body>
|
||||
<div style="width: 400px; max-height: 300px; overflow: hidden;">
|
||||
<div style="width: 400px; height: 300px; overflow: hidden; font-smooth: never;">
|
||||
<h1 class="h1">Testing</h1>
|
||||
<div class="mw9 center ph3-ns">
|
||||
<div class="cf ph2-ns">
|
||||
|
||||
39
windows.py
Normal file
39
windows.py
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
import imgkit
|
||||
from PIL import Image
|
||||
|
||||
config = imgkit.config(wkhtmltoimage='C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltoimage.exe')
|
||||
|
||||
print("Generating html...")
|
||||
|
||||
|
||||
print("Converting to image...")
|
||||
imgkit.from_file('./test.html', 'in.png',
|
||||
config=config,
|
||||
options={
|
||||
'format': 'png',
|
||||
'crop-h': '300',
|
||||
'crop-w': '400'
|
||||
})
|
||||
|
||||
img = Image.open('./in.png')
|
||||
|
||||
# Resize image
|
||||
w, h = img.size
|
||||
|
||||
h_new = 300
|
||||
w_new = int((float(w) / h) * h_new)
|
||||
w_cropped = 400
|
||||
img = img.resize((w_new, h_new), resample=Image.LANCZOS)
|
||||
x0 = (w_new - w_cropped) / 2
|
||||
x1 = x0 + w_cropped
|
||||
y0 = 0
|
||||
y1 = h_new
|
||||
img = img.crop((x0, y0, x1, y1))
|
||||
|
||||
pal_img = Image.new('P', (1,1))
|
||||
pal_img.putpalette((255,255,255,0,0,0,0,0,0) + (0,0,0) * 252)
|
||||
|
||||
img = img.convert("RGB").quantize(palette=pal_img)
|
||||
img.save('out.bmp')
|
||||
print("Done!")
|
||||
Reference in New Issue
Block a user