the public repo for the e-paper bulletin board. It's a bulletin board that syncs over scuttlebutt :)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

58 lines
1.2 KiB

#!/usr/bin/python
# -*- coding:utf-8 -*-
#this script takes a file as an option and adds that file to the db
import optparse
import traceback
import os, sys
import time
import uuid
import subprocess
import epd4in2
import traceback
from PIL import Image,ImageDraw,ImageFont
#generate unique file_name
unique = uuid.uuid4()
unique = str(unique)
jpgpath = 'photos/' + unique + '.jpg'
bmppath = 'photos/' + unique + '.bmp'
#take photo
try:
result = subprocess.call(['raspistill', '-o', jpgpath])
print (result)
except:
print 'traceback.format_exc():\n%s' % traceback.format_exc()
exit()
time.sleep(3)
#convert
size = 400, 300
im = Image.open(jpgpath)
print("opening...")
print (jpgpath)
im = im.rotate(180, Image.NEAREST, "expand=1")
im.thumbnail(size, Image.BICUBIC)
im = im.convert("1")
im.save(bmppath)
print("saving to...")
print (bmppath)
#print!
try:
epd = epd4in2.EPD()
epd.init()
Himage2 = Image.new('1', (epd4in2.EPD_WIDTH, epd4in2.EPD_HEIGHT), 255) # 255: clear the frame
bmp = Image.open(bmppath)
Himage.paste(bmp)
epd.display(epd.getbuffer(Himage))
time.sleep(2)
epd.sleep()
except:
print 'traceback.format_exc():\n%s' % traceback.format_exc()
exit()