import imageio
import os
filepath = 'output/'
images = []
filenames=sorted((filepath+fn for fn in os.listdir(filepath) if fn.endswith('.png'))) # 获取该目录所有的图片文件for filename in filenames:
images.append(imageio.imread(filename))
imageio.mimsave('gif.gif', images,duration=0.2)
修改图片尺寸
import os
from PIL import Image
#读取图像
filepath = 'condgan_output/'
images = []
filenames=sorted((fn for fn in os.listdir(filepath) if fn.endswith('.png')))
for filename in filenames:
im = Image.open(filepath+filename)
im_resized = im.resize((256, 256))
im_resized.save(filepath+filename)