美文网首页
如何将tif文件批量转成png文件

如何将tif文件批量转成png文件

作者: 不爱吃饭的小孩怎么办 | 来源:发表于2019-03-25 14:03 被阅读0次

网上找了很多资料,比如通过网站免费转换,但是突然发现需要收费,我用python难得到我吗?

import os
from PIL import Image

original_path = u'/media/spring/文档/PHZ02000128/'
saved_path = u'/media/spring/文档/PHZ02000128_png/'

counts = 0
files = os.listdir(original_path)
for file in files:
    if file.endswith('tif'):
        tif_file = os.path.join(original_path, file)

        file = file[:-3] + 'png'
        png_file = os.path.join(saved_path, file)
        im = Image.open(tif_file)
        im.save(png_file)
        print(png_file)
        counts += 1

print('%d done' %counts)

相关文章

网友评论

      本文标题:如何将tif文件批量转成png文件

      本文链接:https://www.haomeiwen.com/subject/vtivvqtx.html