From 59b01d7106203f7a36c1e2ec7cdb5ee5d2d7007e Mon Sep 17 00:00:00 2001 From: Paul Friederichsen Date: Sat, 30 Sep 2023 13:36:15 -0500 Subject: [PATCH] Fix colors for PSDs (#1449) * Fix colors for PSDs `HydrusImageHandling.DequantizeNumPyImage` should only be applied to images that are BGR (eg those directly from opencv). PIL produces RGB images already so this was inverting the colors on PSD thumbnails. Instead we use `HydrusImageHandling.DequantizePILImage` to handle edge cases. * Dequantize the PSD PIL image before resizing --- hydrus/core/HydrusPSDHandling.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hydrus/core/HydrusPSDHandling.py b/hydrus/core/HydrusPSDHandling.py index 4594aea30..e0762dac4 100644 --- a/hydrus/core/HydrusPSDHandling.py +++ b/hydrus/core/HydrusPSDHandling.py @@ -44,14 +44,13 @@ def GenerateThumbnailNumPyFromPSDPath( path: str, target_resolution: typing.Tupl if clip_rect is not None: pil_image = HydrusImageHandling.ClipPILImage( pil_image, clip_rect ) + + pil_image = HydrusImageHandling.DequantizePILImage( pil_image ) - thumbnail_pil_image = pil_image.resize( target_resolution, PILImage.LANCZOS ) numpy_image = HydrusImageHandling.GenerateNumPyImageFromPILImage(thumbnail_pil_image) - numpy_image = HydrusImageHandling.DequantizeNumPyImage( numpy_image ) - return numpy_image