This commit is contained in:
2024-11-29 18:15:30 +00:00
parent 40aade2d8e
commit bc9415586e
5298 changed files with 1938676 additions and 80 deletions

View File

@ -0,0 +1,36 @@
import io
from PIL import Image
# def _coder(im):
# if im:
# data = {
# 'pixels': im.tobytes(),
# 'size': im.size,
# 'mode': im.mode,
# }
# return data
#
#
# def _decoder(data):
# if data:
# im = Image.frombytes(data['mode'], data['size'], data['pixels'])
# return im
def _coder(im):
if im:
b = io.BytesIO()
im.save(b, format="png")
data = b.getvalue()
return data
def _decoder(data):
if data:
b = io.BytesIO(data)
im = Image.open(b)
return im
codec = (_coder, _decoder)