From 18307e95a0740ae536db438dae1f53324ad42a13 Mon Sep 17 00:00:00 2001 From: Chongyang Ma Date: Sat, 11 Nov 2017 23:09:44 -0800 Subject: [PATCH] save alpha channel into separate file --- scripts/fill_background.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/fill_background.py b/scripts/fill_background.py index 7909dd5..441983d 100644 --- a/scripts/fill_background.py +++ b/scripts/fill_background.py @@ -23,7 +23,11 @@ def fill_image_background(input_path, output_path, color_r=0, color_g=0, color_b py = int((ht - img.size[1]) / 2) bg.paste(output, (px, px, px + img.size[0], py + img.size[1])) output = bg.copy() + bg.paste(alpha, (px, px, px + img.size[0], py + img.size[1])) + alpha = bg.copy() output.save(output_path) + output_path = output_path.replace(".png", "_alpha.png") + alpha.save(output_path) return True def fill_background(input_path, output_path, color_r=0, color_g=0, color_b=0, wd=0, ht=0):