File tree Expand file tree Collapse file tree 3 files changed +13
-19
lines changed
Expand file tree Collapse file tree 3 files changed +13
-19
lines changed Original file line number Diff line number Diff line change @@ -790,25 +790,17 @@ def _blender(filepath: Path) -> Image.Image | None:
790790 )
791791 im : Image .Image | None = None
792792 try :
793- blend_image = blend_thumb (str (filepath ))
794-
795- bg = Image .new ("RGB" , blend_image .size , color = bg_color )
796- bg .paste (blend_image , mask = blend_image .getchannel (3 ))
797- im = bg
798-
799- except (
800- AttributeError ,
801- UnidentifiedImageError ,
802- TypeError ,
803- ) as e :
804- if str (e ) == "expected string or buffer" :
793+ if (blend_image := blend_thumb (str (filepath ))) is not None :
794+ bg = Image .new ("RGB" , blend_image .size , color = bg_color )
795+ bg .paste (blend_image , mask = blend_image .getchannel (3 ))
796+ im = bg
797+ else :
805798 logger .info (
806799 f"[ThumbRenderer][BLENDER][INFO] { filepath .name } "
807- f "Doesn't have an embedded thumbnail. ( { type ( e ). __name__ } ) "
800+ "Doesn't have an embedded thumbnail."
808801 )
809-
810- else :
811- logger .error ("Couldn't render thumbnail" , filepath = filepath , error = type (e ).__name__ )
802+ except Exception as e :
803+ logger .error ("Couldn't render thumbnail" , filepath = filepath , error = type (e ).__name__ )
812804 return im
813805
814806 @staticmethod
Original file line number Diff line number Diff line change 3232from PIL import Image , ImageOps
3333
3434
35- def blend_extract_thumb (path ):
35+ def blend_extract_thumb (path ) -> tuple [ bytes | None , int , int ] :
3636 rend = b"REND"
3737 test = b"TEST"
3838
@@ -97,8 +97,10 @@ def blend_extract_thumb(path):
9797 return image_buffer , x , y
9898
9999
100- def blend_thumb (file_in ):
100+ def blend_thumb (file_in ) -> Image . Image | None :
101101 buf , width , height = blend_extract_thumb (file_in )
102+ if buf is None :
103+ return None
102104 image = Image .frombuffer (
103105 "RGBA" ,
104106 (width , height ),
Original file line number Diff line number Diff line change @@ -383,7 +383,7 @@ def hasHeightForWidth(self) -> bool:
383383 @override
384384 def itemAt (self , index : int ) -> QLayoutItem :
385385 if index >= len (self ._items ):
386- return None
386+ return None # pyright: ignore[reportReturnType]
387387 return self ._items [index ]
388388
389389 @override
You can’t perform that action at this time.
0 commit comments