From 2c1ce0d5226c5e5b7a9c03c15bf03eacc495fcc4 Mon Sep 17 00:00:00 2001 From: Nicolas F Date: Tue, 12 Mar 2019 00:41:57 +0100 Subject: [PATCH] contrib/png-it: allow saving to stdout with - Following the same convention as some other tools, - as output filename means stdout now. --- contrib/png-it.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/contrib/png-it.py b/contrib/png-it.py index 7acf7e5..7a16a1e 100644 --- a/contrib/png-it.py +++ b/contrib/png-it.py @@ -45,9 +45,10 @@ def main(): parser.error("You cannot specify --center or --crop with --autocrop.") # check for the output - folder, filename = split(args.output) - if folder != '' and not exists(folder): - parser.error("The destination folder '{0}' doesn't exist.".format(folder)) + if args.output != '-': + folder, filename = split(args.output) + if folder != '' and not exists(folder): + parser.error("The destination folder '{0}' doesn't exist.".format(folder)) # calculate stuff n = args.zoom_level @@ -148,7 +149,7 @@ def main(): print("Pasted {0} of {1}.".format(counter, total), file=sys.stderr) print("Done!", file=sys.stderr) print("Saving image... (this may take a while)", file=sys.stderr) - final_img.save(args.output, "PNG") + final_img.save(args.output if args.output != '-' else sys.stdout, "PNG") def get_cropped_centered_img_coords(options, tile_size, center_vector, crop, t):