diff --git a/core/poster_gen.py b/core/poster_gen.py index e8e9437..4c256ec 100644 --- a/core/poster_gen.py +++ b/core/poster_gen.py @@ -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")