Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python PIL错误_Python_Matplotlib_Python Imaging Library_Pillow - Fatal编程技术网

python PIL错误

python PIL错误,python,matplotlib,python-imaging-library,pillow,Python,Matplotlib,Python Imaging Library,Pillow,尝试编写一个python脚本,从文件中获取图像,调整其大小,并将其放入一个新文件中,然后将所有这些图像相邻地组合在一起。这就是我所拥有的,但我得到了很多错误,只能调整大小和重命名图像,而不能合并。救命啊 from __future__ import print_function import PIL import matplotlib.pyplot as plt # single use of plt is commented out import os.path import PIL.Im

尝试编写一个python脚本,从文件中获取图像,调整其大小,并将其放入一个新文件中,然后将所有这些图像相邻地组合在一起。这就是我所拥有的,但我得到了很多错误,只能调整大小和重命名图像,而不能合并。救命啊

from __future__ import print_function
import PIL
import matplotlib.pyplot as plt # single use of plt is commented out
import os.path  
import PIL.ImageDraw     
import glob
from PIL import Image


import os, sys
path = "U:/img/"
dirs = os.listdir(path)

def resize():
    for item in dirs:
        if os.path.isfile(path+item):
            im = Image.open(path+item)
            f, e = os.path.splitext(path+item)
            imResize = im.resize((400,400), Image.ANTIALIAS)
            imResize.save('U:/new/' + item + ' resized.jpg', 'JPEG', quality=90)
             if IOError:
                 pass
         if IOError:
             pass
         if OSError:
             pass
     return

 def combine():
     resize()
     files = [ 
        'U:/new/dinosaur_stock___14_by_nigav_stock-d68h3eh.jpg resized'
        'U:/new/imgres.jpg resized'
        'U:/new/stock-footage-guide1.jpg resized'
    ] 
     result = Image.new("RGB", (800, 800)) 


    for index, file in enumerate(files): 
        path = os.path.expanduser(file) 
        img = Image.open(path) 
        img.thumbnail((400, 400), Image.ANTIALIAS) 
        x = index // 2 * 400 
        y = index % 2 * 400 
        w, h = img.size 
        print('pos {0},{1} size {2},{3}'.format(x, y, w, h)) 
        result.paste(img, (x, y, x + w, y + h)) 


        result.save(os.path.expanduser('~/image.jpg'))
        if IOError:
            pass
        if OSError:
            pass 
combine()

“我有很多错误”不是一个足够的问题描述。首先,我想
'U:/new/imgres.jpg resized'
不是正确的文件名。一旦你解决了这个问题并且仍然得到错误,你就需要包含完整的错误回溯。所有这些
如果IOError:
和类似的方法都一事无成。我想你是想用
试试…
。。。IOError除外: