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

网上找了很多资料,比如通过网站免费转换,但是突然发现需要收费,我用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文件)