27 lines
642 B
Python
27 lines
642 B
Python
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)
|