将图像从一个文件复制到python文件夹

时间:2018-08-21 07:15:16

标签: python python-imaging-library

我在python-3.6中使用了conda接口,它没有将图像保存到指定的路径。我在做什么错了?

import os
from PIL import Image
from shutil import copyfile

dire=r'C:\Users\JZ\Desktop\books'
fnames = [r'C:\Users\JZ\Desktop\DLIMAGES\WarningsNegative.{}.jpg'.format(i) for i in range(0, 1665)]
gnames=['Warnings.{}'.format(i) for i in range(0, 1665)]

for each in range(0,1665):
    path=os.path.join(dire,gnames[each])


    print('dst=', path)
    im=Image.open(fnames[each])
    temp=im.copy()
    #gene=str(path).replace("\\","/")
    with open(path,'wb') as newline:
         temp.save(newline,"JPEG")

0 个答案:

没有答案