python-codecs: fix gray conversion

This commit is contained in:
Koushik Dutta
2023-04-26 18:40:22 -07:00
parent fc102aa526
commit 2609e301fe
3 changed files with 13 additions and 4 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/python-codecs",
"version": "0.1.46",
"version": "0.1.47",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@scrypted/python-codecs",
"version": "0.1.46",
"version": "0.1.47",
"devDependencies": {
"@scrypted/sdk": "file:../../sdk"
}

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/python-codecs",
"version": "0.1.46",
"version": "0.1.47",
"description": "Python Codecs for Scrypted",
"keywords": [
"scrypted",

View File

@@ -35,7 +35,16 @@ class PILImage(scrypted_sdk.VideoFrame):
finally:
rgb.close()
return await to_thread(format)
# TODO: gray...
elif options['format'] == 'gray':
def format():
if pilImage.pilImage.mode == 'L':
return pilImage.pilImage.tobytes()
l = pilImage.pilImage.convert('L')
try:
return l.tobytes()
finally:
l.close()
return await to_thread(format)
def save():
bytesArray = io.BytesIO()