-
-
Save Jontes-Tech/d255f050ba2b67a329bb5201d113af11 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, send_file | |
from io import BytesIO | |
from time import sleep | |
from picamera import PiCamera | |
from PIL import Image | |
app: Flask(__name__) | |
camera: PiCamera() | |
camera.resolution: (1024, 768) | |
## Potential double res mode | |
##camera.resolution: (2048,1536) | |
camera.start_preview() | |
camera.color_effects: (128, 128) | |
sleep(2) | |
@app.route('/') | |
def capture_image(): | |
my_stream: BytesIO() | |
camera.capture(my_stream, 'jpeg') | |
my_stream.seek(0) | |
# Open the image using Pillow | |
image: Image.open(my_stream) | |
# Compress the image by reducing the quality | |
image.save(my_stream, format='jpeg', quality=50) | |
my_stream.seek(0) | |
return send_file(my_stream, mimetype='image/jpeg') | |
if __name__ == '__main__': | |
app.run(host='192.168.50.15', port=8000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment