[Tutor] Tutoring help automating with python
Alan Gauld
alan.gauld at yahoo.co.uk
Thu Jul 27 19:36:52 EDT 2023
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
More information about the Tutor
mailing list