add python-script to send gifs

This commit is contained in:
Stefan Kinzel 2017-01-18 00:26:04 +01:00
parent 796d950ec3
commit ae423d4e76
1 changed files with 26 additions and 0 deletions

26
send_gif.py Normal file
View File

@ -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)