python 图片tif转jpg或png

import cv2

import os

 

tif_path = ''

jpg_path = ''

 

imgs = os.listdir(tif_path)

for i, img in enumerate(imgs):

    img_name = os.path.join(tif_path, img)

    file = cv2.imread(img_name, 1)

    save_file = os.path.join(jpg_path, img.strip('.tif')+'.jpg')

    cv2.imwrite(save_file, file)

    print(i)

你可能感兴趣的:(python)