Files
jigsaw/mask_split.py
2024-12-03 11:34:51 +13:00

15 lines
347 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from PIL import Image
from PIL import Image
# 打开目标图片和线条蒙版
image = Image.open("birds.png").convert("RGBA")
mask = Image.open("mask.png").convert("L") # 灰度图
# 将蒙版应用到图片上
# mask 是透明区域255 表示不透明0 表示完全透明
image.putalpha(mask)
# 保存结果
image.save("result.png")