import os
from PIL import Image, ImageDraw, ImageFont
def batch_convert_webp_to_png(output_folder):
input_folder = os.getcwd() # 获取当前工作目录的路径
# 遍历输入文件夹中的所有文件
for filename in os.listdir(input_folder):
if filename.endswith('.webp'):
# 构建输入文件的完整路径
input_path = os.path.join(input_folder, filename)
# 构建输出文件的完整路径
output_filename = os.path.splitext(filename)[0] + '.png'
output_path = os.path.join(output_folder, output_filename)
# 执行WebP到PNG的转换并缩放
image = Image.open(input_path)
image.thumbnail((750, 1000)) # 等比缩放
# 创建新图像并用白色填充
resized_image = Image.new('RGB', (750, 1000), (0, 0, 0))
# 在新图像上绘制文本
draw = ImageDraw.Draw(resized_image)
# 设置字体和大小
font = ImageFont.truetype('SourceHanSans-Bold.otf', 60)
text1 = "24小时自动发货"
text2 = "kkxv"
text1_bbox = draw.textbbox((0, 0), text1, font=font)
text2_bbox = draw.textbbox((0, 0), text2, font=font)
text1_width = text1_bbox[2] - text1_bbox[0]
text1_height = text1_bbox[3] - text1_bbox[1]
text2_width = text2_bbox[2] - text2_bbox[0]
text2_height = text2_bbox[3] - text2_bbox[1]
# 绘制顶部文本
draw.text(((750 - text1_width) // 2, 20), text1, fill=(255, 255, 255), font=font)
draw.text(((750 - text2_width) // 2, 1000 - text2_height - 20), text2, fill=(255, 255, 255), font=font) # 绘制底部文本
resized_image.paste(image, ((750 - image.width) // 2, (1000 - image.height) // 2)) # 粘贴缩放后的图像
resized_image.save(output_path, 'PNG', optimize=True)
# 示例用法
output_folder = os.getcwd() # 保存PNG图像的输出文件夹路径
batch_convert_webp_to_png(output_folder)
webp 转 PNG
About Me
I am a seasoned game development programmer with 16 years of extensive work experience. I am passionate about game development and dedicated to creating awe-inspiring gaming experiences. Through my technical skills and creativity, I constantly drive the progress of the gaming industry.
我是一名资深游戏开发工程师,拥有16年的丰富工作经验。我对游戏开发充满热情,并致力于创造令人惊叹的游戏体验。通过我的技术和创意,我不断推动游戏行业的发展。
Programming Languages: I am proficient in several programming languages, including C++, C#, Golang、Python, and more. I skillfully utilize these languages to implement core functionalities, optimize performance, and ensure game stability.
编程语言:我精通多种编程语言,包括C++、C#、Golang、Python等。我熟练运用这些语言来实现游戏的核心功能,优化性能,并确保游戏的稳定性。
Game Engines: I have extensive experience with multiple game engines, including Unity and Unreal Engine. I leverage the powerful features of these engines to create visually stunning game worlds.
游戏引擎:我在多个游戏引擎上有丰富的经验,包括Unity和Unreal Engine。我能够利用这些引擎的强大功能,打造出精美绝伦的游戏世界。
Recent Posts
2d ultimate bundle Advanced Culling System 2 Animated 2D Monsters ca Dark Pixel UI Fantazia final cut pro 10.6.10 fps Gaia Pro 2023 game ai gena pro hackmssql ip欺诈 ip解析 Low Poly Shooter Pack mod nms Parallels desktop Parallels desktop 19 for mac 免费激活方法 php php8.0 php8.1 Post Apocalyptic Destroyed Buildings projectzomboid scum soft-nms terrains unity unity asset vpn vpn搭建 vps windows11免费激活 xmind yolov5 yolov5+ca+soft-nms 人渣弹幕mod 信息对称平台 僵尸毁灭工程弹幕mod 弹幕游戏 有点用的网站 梯子搭建 激活码 科学上网 黑进服务器