import imgkit

from PIL import Image
from inky import InkyWHAT
from inky.auto import auto

display = auto(verbose = True)

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', 
                 config=config,
                 options={
    'format': 'png',
    'crop-h': '300',
    'crop-w': '400'
})

img = Image.open('./out.png')

pal_img = Image.new('P', (1,1))
pal_img.putpalette((255,255,255,0,0,0,255,0,0) + (0,0,0) * 252)

img = img.convert("RGB").quantize(palette=pal_img)

print("Updating display...")
display.set_image(img)
display.show()

print("Done!")
