diff --git a/README.md b/README.md index 2159807..ee0be46 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,22 @@ # Thermal-Printer-Camera -Thermal printer prints photos from Raspberry Pi camera. \ No newline at end of file +Thermal printer prints photos from Raspberry Pi camera. +Will be used on public events to show example projects and produce small give-aways for kids. + +Uses Python and esc-pos. + + +## Requirements +To install on Raspian install following dependencies: +``` +sudo apt-get install python3-pip +sudo pip3 install python-escpos +``` + +## ToDos +- [x] Working camera +- [x] Nice background picture +- [ ] Add buzzer to take picture +- [ ] Add Case for Raspberry Pi and camera +- [ ] Integrate everything into priner +- [ ] Add lighting for camera diff --git a/background.png b/background.png new file mode 100644 index 0000000..f803884 Binary files /dev/null and b/background.png differ diff --git a/background.svg b/background.svg new file mode 100644 index 0000000..f98dad3 --- /dev/null +++ b/background.svg @@ -0,0 +1,553 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tpc.py b/tpc.py new file mode 100755 index 0000000..62db583 --- /dev/null +++ b/tpc.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 + + +from escpos import printer +from picamera import PiCamera +from PIL import Image +from io import BytesIO +import time + +p = printer.Usb(0x0493, 0x8760, in_ep=0x81, out_ep=0x03) + + +camera = PiCamera() +camera.resolution = (284, 284) + + +def capture(width=284, height=284): + stream = BytesIO() + camera.resolution = (width, height) + camera.capture(stream, format='jpeg') + stream.seek(0) + return stream + + +def main(): + # wait for camera to initialize + sleep(1) + image = Image.open(capture(284,284)) + image.seek(0) + + background = Image.open("background.png") + foreground = Image.open("background.png") + + background.paste(image, (50,50)) + background.paste(foreground, (0, 0), foreground) + + # Optional: save image + # timestr = time.strftime("%Y%m%d-%H%M%S") + #background.save(timestr+".png", "PNG") + + p.image(background, high_density_vertical=True, high_density_horizontal=True, fragment_height=1) + + +if __name__ == '__main__': + main()