From 0bff96a6e6cee4a07b36e4e8a99e3edc0696f0a3 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Tue, 28 Mar 2023 19:27:22 -0700 Subject: [PATCH] python-codecs: pil crop is not thread safe https://github.com/python-pillow/Pillow/issues/4848 --- plugins/python-codecs/package-lock.json | 4 ++-- plugins/python-codecs/package.json | 2 +- plugins/python-codecs/src/pilimage.py | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/python-codecs/package-lock.json b/plugins/python-codecs/package-lock.json index f8b2aae04..e013e9b5a 100644 --- a/plugins/python-codecs/package-lock.json +++ b/plugins/python-codecs/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/python-codecs", - "version": "0.1.22", + "version": "0.1.25", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@scrypted/python-codecs", - "version": "0.1.22", + "version": "0.1.25", "devDependencies": { "@scrypted/sdk": "file:../../sdk" } diff --git a/plugins/python-codecs/package.json b/plugins/python-codecs/package.json index 75c1e5ffd..d20524eab 100644 --- a/plugins/python-codecs/package.json +++ b/plugins/python-codecs/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/python-codecs", - "version": "0.1.22", + "version": "0.1.25", "description": "Python Codecs for Scrypted", "keywords": [ "scrypted", diff --git a/plugins/python-codecs/src/pilimage.py b/plugins/python-codecs/src/pilimage.py index 512afd9cd..51896280c 100644 --- a/plugins/python-codecs/src/pilimage.py +++ b/plugins/python-codecs/src/pilimage.py @@ -26,7 +26,7 @@ class PILImage(scrypted_sdk.VideoFrame): elif options['format'] == 'rgb': def format(): rgbx = pilImage.pilImage - if rgbx.format != 'RGBA': + if rgbx.mode != 'RGBA': return rgbx.tobytes() rgb = rgbx.convert('RGB') try: @@ -96,6 +96,7 @@ class ImageReader(scrypted_sdk.ScryptedDeviceBase, scrypted_sdk.BufferConverter) async def convert(self, data: Any, fromMimeType: str, toMimeType: str, options: scrypted_sdk.MediaObjectOptions = None) -> Any: pil = Image.open(io.BytesIO(data)) + pil.load() return await createPILMediaObject(PILImage(pil)) class ImageWriter(scrypted_sdk.ScryptedDeviceBase, scrypted_sdk.BufferConverter):