Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

能否加一个图片处理功能,蒙版,这个生成海报时候非常有用 #19

Open
feelast opened this issue Nov 24, 2024 · 1 comment

Comments

@feelast
Copy link

feelast commented Nov 24, 2024

想处理一下蒙版,这个生成海报时候非常有用
我用python写了一个,就是一个黑白渐变图
和一个正常的图片蒙版。
`#!/usr/bin/python3
import os
from PIL import Image

数据路径

path = "E:\111\titlepic222"
path2 = "E:\111\titlepic2222"

调用示例

for filename in os.listdir(path):

# 打开前景图片和蒙版图片
image_path = os.path.join(path, filename)
foreground = Image.open(image_path)
mask = Image.open("mask.png").convert("L")  # 将蒙版图片转换为灰度图
 
# 应用蒙版
foreground.putalpha(mask)
image_path2 = os.path.join(path2, filename)
foreground.save(image_path2)`
@kkokk
Copy link
Owner

kkokk commented Nov 26, 2024

好的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants