#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 24 10:47:36 2018
@author: yxh
"""
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
import os
import sys
import shutil
path='F:/code/pytorch-deeplab-xception-master/dataloaders/datasets/invoice/SegmentationClass3/'
newpath='F:/code/pytorch-deeplab-xception-master/dataloaders/datasets/invoice/SegmentationClass'
def turnto24(path):
files = os.listdir(path)
files = np.sort(files)
i=0
for f in files:
imgpath = path + f
img=Image.open(imgpath).convert('P')
dirpath = newpath
file_name, file_extend = os.path.splitext(f)
dst = os.path.join(os.path.abspath(dirpath), file_name + '.png')
img.save(dst)
turnto24(path)
python修改图片的大小
最新推荐文章于 2023-12-04 11:40:59 发布