如何使用Python批量转换图片格式?

2026-05-21 20:150阅读0评论SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计134个文字,预计阅读时间需要1分钟。

如何使用Python批量转换图片格式?

伪原创可以改写为创意改编。以下是改写后的开头内容:

创意改编,让内容焕发新生!

# python 图片批量格式转换
import glob
import os
import threading

from PIL import Image


def create_image(infile, index):
os.path.splitext(infile)
im = Image.open(infile)
im.save(str(index) + ".png", "PNG")


def start():
index = 0
for infile in glob.glob("./*.webp"):
t = threading.Thread(target=create_image, args=(infile, index,))
t.start()
t.join()
index += 1


if __name__ == "__main__":
start()


如何使用Python批量转换图片格式?

本文共计134个文字,预计阅读时间需要1分钟。

如何使用Python批量转换图片格式?

伪原创可以改写为创意改编。以下是改写后的开头内容:

创意改编,让内容焕发新生!

# python 图片批量格式转换
import glob
import os
import threading

from PIL import Image


def create_image(infile, index):
os.path.splitext(infile)
im = Image.open(infile)
im.save(str(index) + ".png", "PNG")


def start():
index = 0
for infile in glob.glob("./*.webp"):
t = threading.Thread(target=create_image, args=(infile, index,))
t.start()
t.join()
index += 1


if __name__ == "__main__":
start()


如何使用Python批量转换图片格式?