暂时停止了贴纸模块的使用
This commit is contained in:
parent
1a8ddef1ff
commit
4aa55127c6
@ -125,7 +125,6 @@ class PosterGenerator:
|
||||
|
||||
def _initialize_stickers(self):
|
||||
"""初始化贴纸素材"""
|
||||
stickers = []
|
||||
try:
|
||||
sticker_files = [f for f in os.listdir(self.sticker_dir) if f.endswith(('.png'))]
|
||||
print(f"找到贴纸素材: {sticker_files}")
|
||||
@ -684,13 +683,14 @@ class PosterGenerator:
|
||||
# 获取海报尺寸
|
||||
width, height = poster_image.size
|
||||
|
||||
# 决定是否添加贴纸(50%概率)
|
||||
if random.random() < 0.5:
|
||||
# 决定是否添加贴纸(25%概率添加)
|
||||
if random.random() < 0.75:
|
||||
print("随机决定不添加贴纸")
|
||||
return poster_image
|
||||
|
||||
# 随机决定添加1-3个贴纸
|
||||
sticker_count = random.randint(1, 3)
|
||||
sticker_count = 1
|
||||
# sticker_count = random.randint(1, 3)
|
||||
print(f"准备添加 {sticker_count} 个贴纸")
|
||||
|
||||
# 创建一个新图层用于合成
|
||||
@ -794,9 +794,10 @@ class PosterGenerator:
|
||||
final_poster.alpha_composite(text_layer)
|
||||
|
||||
# (可选) 添加贴纸
|
||||
final_poster = self.add_stickers(final_poster)
|
||||
print("Layers composed.")
|
||||
# final_poster = self.add_stickers(final_poster)
|
||||
# print("Layers composed.")
|
||||
|
||||
|
||||
# 转换回 RGB 以保存为 JPG/PNG (移除 alpha通道)
|
||||
final_poster_rgb = final_poster.convert("RGB")
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user