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

@@ -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()