Skip to content

Commit

Permalink
Fix colors for PSDs (#1449)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
floogulinc authored Sep 30, 2023
1 parent b4afedb commit 59b01d7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions hydrus/core/HydrusPSDHandling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 59b01d7

Please sign in to comment.