Add option --background.

This commit is contained in:
voussoir 2023-09-14 21:12:21 -07:00
parent db2fab6628
commit 73df06730f

View file

@ -53,7 +53,8 @@ def stitch_argparse(args):
final_width = sum(column_widths) + ((grid_x - 1) * args.gap) final_width = sum(column_widths) + ((grid_x - 1) * args.gap)
final_height = sum(row_heights) + ((grid_y - 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 offset_y = 0
for (index_y, row) in enumerate(arranged_images): 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. 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) parser.set_defaults(func=stitch_argparse)
return betterhelp.go(parser, argv) return betterhelp.go(parser, argv)