diff --git a/send_gif.py b/send_gif.py new file mode 100644 index 0000000..3ff6d8f --- /dev/null +++ b/send_gif.py @@ -0,0 +1,26 @@ +from os import listdir +from PIL import Image +import paho.mqtt.publish as publish +import time + +C_BLACK = 0 +C_WHITE = 255 + +for img in listdir("."): + print(img) + if img[-3:] == "gif": + print("converting " + img) + image = Image.open(img) + image = image.convert(mode='RGBA') + image = image.resize((80,16)) + imgmap = "" + for pixel in image.getdata(): + r, g, b, a = pixel + if r == C_WHITE: + imgmap += "1" + else: + imgmap += "0" + + publish.single("raum2/flipdot/image", imgmap, hostname="raum.ctdo.de") + + time.sleep(1)