From 73df06730ff4c6a9cc858260eb12635ca298d8a8 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 14 Sep 2023 21:12:21 -0700 Subject: [PATCH] Add option --background. --- stitch.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/stitch.py b/stitch.py index c2ac4e0..a25bd07 100644 --- a/stitch.py +++ b/stitch.py @@ -53,7 +53,8 @@ def stitch_argparse(args): final_width = sum(column_widths) + ((grid_x - 1) * args.gap) final_height = sum(row_heights) + ((grid_y - 1) * args.gap) - final_image = PIL.Image.new('RGBA', [final_width, final_height]) + background = '#' + args.background.strip('#') + final_image = PIL.Image.new('RGBA', [final_width, final_height], color=background) offset_y = 0 for (index_y, row) in enumerate(arranged_images): @@ -114,6 +115,16 @@ def main(argv): This many pixels of transparent gap between each row / column. ''', ) + parser.add_argument( + '--background', + type=str, + default='#00000000', + help=''' + Background color as a four-channel (R, G, B, A) hex string. + This color will be seen in the --gap and behind any images that + already had transparency. + ''', + ) parser.set_defaults(func=stitch_argparse) return betterhelp.go(parser, argv)