开发者

Python image conversion

开发者 https://www.devze.com 2023-02-22 02:51 出处:网络
I have a lis开发者_如何学Ct of images names which are associated with real resources in file system. For example:

I have a lis开发者_如何学Ct of images names which are associated with real resources in file system. For example:

'image1.png'
'image2.jpg'
'image3.jpeg'

I have to conver all of them into png with the same name. How can I do that in python?

The ideas are: using PIL or ImageMagic.


from PIL import Image
import os
for filename in filelist:
    basename, ext = os.path.splitext(filename)
    if ext.lower() == ".png":
        continue
    img = Image.open(filename)
    img.save(basename + ".png")
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号