asd
This commit is contained in:
36
venv/lib/python3.12/site-packages/pyscreenshot/imcodec.py
Normal file
36
venv/lib/python3.12/site-packages/pyscreenshot/imcodec.py
Normal 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)
|
||||
Reference in New Issue
Block a user