add python-script to send gifs
This commit is contained in:
parent
796d950ec3
commit
ae423d4e76
|
@ -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)
|
Loading…
Reference in New Issue