mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-11-14 00:43:50 +00:00
decode image from data url
This commit is contained in:
parent
c4e3d04043
commit
0831e751c3
@ -3,7 +3,8 @@ from deps.samplebase import SampleBase
|
||||
from rgbmatrix import graphics
|
||||
from typing import Optional
|
||||
from PIL import Image
|
||||
import requests
|
||||
import base64
|
||||
import io
|
||||
|
||||
from flask import Flask, request, jsonify
|
||||
from flask_cors import CORS, cross_origin
|
||||
@ -289,7 +290,9 @@ class Matrix(SampleBase):
|
||||
|
||||
# set current image
|
||||
def set_image(self, url: str):
|
||||
self.image = Image.open(requests.get(url, stream=True).raw)
|
||||
_, data = url.split(',')
|
||||
data = base64.b64decode(data)
|
||||
self.image = Image.open(io.BytesIO(data)).convert('RGB')
|
||||
|
||||
# display image at position with dimensions in current color
|
||||
def display_image(self, x: int, y: int):
|
||||
|
Loading…
Reference in New Issue
Block a user