Re: Tutoring help automating with python

Alan Gauld via Tutor <[email protected]>
Newsgroups gmane.comp.python.tutor
Message-ID <[email protected]>
The immediate issue has been identified. Here are
some other things to consider...

On 26/07/2023 21:17, Fatima Mehak wrote:
> def resize_rename_rotate(srcfile, targetdir="", size=(128,128)):
>         targetfile = os.path.splitext(srcfile)[0]
>         extension = os.path.splitext(srcfile)[1]
> 
>         if srcfile != tgtfile:

What is tgtfile? Where is it defined?


>             try :
>                  im = Image.open(srcfile)  # open file
>                  im.rotate(90) # degrees counter-clockwise
>                  im.resize((128, 128)) # resize the file

Shouldn't this use the size parameter instead of a hard coded (128,128)?

>                  im.save(targetdir+targetfile+extension,"jpeg")
>             except IOError:
>                 print ("cannot change image for ", srcfile)


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



_______________________________________________
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.