无法将调整大小后的图像写入文件夹

时间:2019-07-30 02:51:50

标签: python-3.x image-resizing

我想使用Python调整子目录中所有图像的大小。我已经制作了脚本,但是要在其中写那些调整大小后的图像的文件夹给出了Permission Denied Error

下面是我调整图像大小的代码

import os
from PIL import Image
from resizeimage import resizeimage
import glob
from glob import glob
def img_resize(a,b):
    if not os.path.exists(b):
        os.makedirs(b,exist_ok=True)
    img_list=[]
    x = glob(a)

    for file in x:
        for f in glob(file+"/*.jpg"):
            img_list.append(f)

            for i in range(len(img_list)):
                img = Image.open(img_list[i])
                cover = resizeimage.resize_cover(img, [200, 100])
                cover.save(b,img.format)


if __name__ == '__main__':
    m = ("C:\\Python36\\videos\\videos_new\\*")
    n = ("C:\\Python36\\videos\\resized_images")
    img_resize(m,n)

这是在运行代码时出现的错误

C:\Python35\python.exe C:/Users/128938/PycharmProjects/pdf_text_extract/resize4.py
Traceback (most recent call last):
  File "C:/Users/128938/PycharmProjects/pdf_text_extract/resize4.py", line 25, in <module>
    img_resize(m,n)
  File "C:/Users/128938/PycharmProjects/pdf_text_extract/resize4.py", line 19, in img_resize
    cover.save(b,img.format)
  File "C:\Python35\lib\site-packages\PIL\Image.py", line 1991, in save
    fp = builtins.open(filename, "w+b")
PermissionError: [Errno 13] Permission denied: 'C:\\Python36\\videos\\resized_images'

0 个答案:

没有答案