Fungerande i Python 3

This commit is contained in:
2022-01-30 13:57:10 +01:00
parent 86c1b953be
commit b9189c707e

View File

@@ -1,7 +1,7 @@
from PIL import Image
import ST7789 as ST7789
import RPi.GPIO as GPIO
import urllib3
#import urllib3
import requests
import io
import time
@@ -29,11 +29,6 @@ js3 = { "method": "core.library.get_images", "jsonrpc": "2.0", "params": { "uri
js4 = requests.post(url, json=js3)
cover = list(js4.json()['result'].values())[0][0]['uri']
# Fetch image file
http = urllib3.PoolManager()
r = http.request('GET', cover)
image_file = r.data
WIDTH = disp.width
HEIGHT = disp.height
@@ -48,8 +43,9 @@ backlight = GPIO.PWM(13, 500)
backlight.start(100)
# Load an image.
print('Loading image: {}...'.format(image_file))
image = Image.open(image_file)
#print('Loading image: {}...'.format(image_file))
#image = Image.open(image_file)
image = Image.open(requests.get(cover, stream=True).raw)
# Resize the image
image = image.resize((WIDTH, HEIGHT))