@@ -298,6 +298,7 @@ def INPUT_TYPES(cls):
298
298
"height" : ("INT" , {"default" : 512 , "min" : 1 , "max" : MAX_RESOLUTION , "step" : 8 }),
299
299
"lossless_webp" : ("BOOLEAN" , {"default" : True }),
300
300
"quality_jpeg_or_webp" : ("INT" , {"default" : 100 , "min" : 1 , "max" : 100 }),
301
+ "optimize_png" : ("BOOLEAN" , {"default" : False }),
301
302
"counter" : ("INT" , {"default" : 0 , "min" : 0 , "max" : 0xffffffffffffffff }),
302
303
"denoise" : ("FLOAT" , {"default" : 1.0 , "min" : 0.0 , "max" : 1.0 }),
303
304
"time_format" : ("STRING" , {"default" : "%Y-%m-%d-%H%M%S" , "multiline" : False }),
@@ -328,6 +329,7 @@ def save_files(
328
329
modelname ,
329
330
quality_jpeg_or_webp ,
330
331
lossless_webp ,
332
+ optimize_png ,
331
333
width ,
332
334
height ,
333
335
counter ,
@@ -380,12 +382,12 @@ def save_files(
380
382
print (f'The path `{ output_path .strip ()} ` specified doesn\' t exist! Creating directory.' )
381
383
os .makedirs (output_path , exist_ok = True )
382
384
383
- filenames = self .save_images (images , output_path , filename , comment , extension , quality_jpeg_or_webp , lossless_webp , prompt , extra_pnginfo )
385
+ filenames = self .save_images (images , output_path , filename , comment , extension , quality_jpeg_or_webp , lossless_webp , optimize_png , prompt , extra_pnginfo )
384
386
385
387
subfolder = os .path .normpath (path )
386
388
return {"ui" : {"images" : map (lambda filename : {"filename" : filename , "subfolder" : subfolder if subfolder != '.' else '' , "type" : 'output' }, filenames )}}
387
389
388
- def save_images (self , images , output_path , filename_prefix , comment , extension , quality_jpeg_or_webp , lossless_webp , prompt = None , extra_pnginfo = None ) -> list [str ]:
390
+ def save_images (self , images , output_path , filename_prefix , comment , extension , quality_jpeg_or_webp , lossless_webp , optimize_png , prompt = None , extra_pnginfo = None ) -> list [str ]:
389
391
img_count = 1
390
392
paths = list ()
391
393
for image in images :
@@ -405,7 +407,7 @@ def save_images(self, images, output_path, filename_prefix, comment, extension,
405
407
metadata .add_text (x , json .dumps (extra_pnginfo [x ]))
406
408
407
409
filename = f"{ filename_prefix } .png"
408
- img .save (os .path .join (output_path , filename ), pnginfo = metadata , optimize = True )
410
+ img .save (os .path .join (output_path , filename ), pnginfo = metadata , optimize = optimize_png )
409
411
else :
410
412
filename = f"{ filename_prefix } .{ extension } "
411
413
file = os .path .join (output_path , filename )
0 commit comments