修复了透明显示的问题
This commit is contained in:
parent
88e23501b2
commit
4d157453ce
Binary file not shown.
@ -546,8 +546,8 @@ class VibrantTemplate(BaseTemplate):
|
||||
estimated_height = self._estimate_content_height(content)
|
||||
gradient_start = self._detect_gradient_start_position(main_image, estimated_height)
|
||||
|
||||
# 创建新的PSD文档
|
||||
psd = PSDImage.new("RGB", self.size, color=(255, 255, 255))
|
||||
# 创建新的PSD文档(使用透明背景)
|
||||
psd = PSDImage.new("RGBA", self.size, color=(0, 0, 0, 0))
|
||||
logger.info(f"创建PSD文档,尺寸: {self.size}")
|
||||
|
||||
# 1. 添加背景图层
|
||||
@ -570,11 +570,33 @@ class VibrantTemplate(BaseTemplate):
|
||||
psd.append(text_layer)
|
||||
logger.info(f"✓ Added {layer_name} layer")
|
||||
|
||||
# 注意:PSD文件保持原始尺寸,最终调整在导出时进行
|
||||
# 应用与常规模式相同的尺寸调整 (1350x1800)
|
||||
final_size = (1350, 1800)
|
||||
|
||||
# 调整PSD文档尺寸以匹配常规输出
|
||||
if psd.size != final_size:
|
||||
logger.info(f"调整PSD尺寸: {psd.size} -> {final_size}")
|
||||
# 重新创建PSD文档以匹配最终尺寸
|
||||
final_psd = PSDImage.new("RGBA", final_size, color=(0, 0, 0, 0))
|
||||
|
||||
# 调整并添加所有图层
|
||||
for layer in psd:
|
||||
try:
|
||||
if hasattr(layer, 'composite'):
|
||||
layer_image = layer.composite()
|
||||
if layer_image:
|
||||
# 调整图层尺寸
|
||||
resized_layer = layer_image.resize(final_size, Image.LANCZOS)
|
||||
final_layer = PixelLayer.frompil(resized_layer, final_psd, layer.name)
|
||||
final_psd.append(final_layer)
|
||||
except Exception as e:
|
||||
logger.warning(f"调整图层 {layer.name} 失败: {e}")
|
||||
|
||||
psd = final_psd
|
||||
|
||||
# 保存PSD文件
|
||||
psd.save(output_path)
|
||||
logger.info(f"✓ PSD文件已保存: {output_path}")
|
||||
logger.info(f"✓ PSD文件已保存: {output_path} (尺寸: {psd.size})")
|
||||
|
||||
return output_path
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user