@@ -47,18 +47,21 @@ def re_canvas(size: int, img: Image.Image):
4747 # | 256 | 170.666 → 171 | 204.8 → 205 | 256 |
4848
4949 blob = BytesIO ()
50- if width <= 32 or height <= 32 :
51- re_canvas (32 , clone ).save (blob , "PNG" )
52- elif width <= 48 or height <= 48 :
53- re_canvas (48 , clone ).save (blob , "PNG" )
54- elif width <= 64 or height <= 64 :
55- re_canvas (64 , clone ).save (blob , "PNG" )
56- elif width <= 96 or height <= 96 :
57- re_canvas (96 , clone ).save (blob , "PNG" )
58- elif width <= 128 or height <= 128 :
59- re_canvas (128 , clone ).save (blob , "PNG" )
50+ if not image .re_canvas :
51+ if width <= 32 or height <= 32 :
52+ re_canvas (32 , clone ).save (blob , "PNG" )
53+ elif width <= 48 or height <= 48 :
54+ re_canvas (48 , clone ).save (blob , "PNG" )
55+ elif width <= 64 or height <= 64 :
56+ re_canvas (64 , clone ).save (blob , "PNG" )
57+ elif width <= 96 or height <= 96 :
58+ re_canvas (96 , clone ).save (blob , "PNG" )
59+ elif width <= 128 or height <= 128 :
60+ re_canvas (128 , clone ).save (blob , "PNG" )
61+ else :
62+ re_canvas (256 , clone ).save (blob , "PNG" )
6063 else :
61- re_canvas ( 256 , clone ) .save (blob , "PNG" )
64+ image . image .save (blob , "PNG" )
6265
6366 blob .seek (0 )
6467 image_data .append (blob .read ())
0 commit comments