Tutoring help automating with python

Fatima Mehak <[email protected]>
Newsgroups gmane.comp.python.tutor
Message-ID <CAMDQkAeKXzHuhYibb=PkM5jKhbw1z8FSV2yugWRKsw8uMcDVXg@mail.gmail.com>
Hello,
I've been getting errors when trying to run the below text file. I have
indicated the error at the bottom for review. Can you please assist?


#!/usr/bin/env python3

from PIL import Image
import os, sys

def resize_rename_rotate(srcfile, targetdir="", size=(128,128)):
        targetfile = os.path.splitext(srcfile)[0]
        extension = os.path.splitext(srcfile)[1]

        if srcfile != tgtfile:
            try :
                 im = Image.open(srcfile)  # open file
                 im.rotate(90) # degrees counter-clockwise
                 im.resize((128, 128)) # resize the file
                 im.save(targetdir+targetfile+extension,"jpeg")
            except IOError:
                print ("cannot change image for ", srcfile)

if __name__=="__main__":
        targetdir = "../output/"
        srcdir = "../input/"

        for file in os.listdir(srcdir):
             resize_rename_rotate(file,targetdir)





#*Traceback (most recent call last):
#  File "/home/student-03-61dc276e6247/./fix_image.py", line 23, in <module>
#    for file in os.listdir(srcdir):
#FileNotFoundError: [Errno 2] No such file or directory: '../input/'
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.