Aug-14-2020, 10:59 AM
(Aug-13-2020, 02:54 PM)GOTO10 Wrote: Your assignment statements on line 6 and 7 are not doing what you think they are. In each case, you are assigning a variable to the value returned by a function call. Both of these functions just return the Python default value ofNone
, so if you use them later (as you do with new_path in line 26), you are passing a value ofNone
. When you make the call on line 26, you need to ensure that you are passing a valid path and filename, so make sure you're assigning your path variables the values you actually want them to contain.
Also, be aware thatos.makedirs('Thumbnails')
will fail if the Thumbnails folder already exists. Here is one way to correctly assign a variable to the desired thumbnails path and create that folder only if it doesn't already exist (this do:
path = input("Where are your images? > ") # you should probably add code here to verify that the path entered by the user is valid before proceeding thumb_path = (path + '\\Thumbnails') if not os.path.exists(thumb_path): os.mkdir(thumb_path)
Thank you for that - that's a great help!
The images are saving to the created folder (which is great) but I am now getting the print message from line 13 (regarding invalid file type) - is there a way in which I can still keep the
new_size.save( "Thumbnail " + fn + ext)that now works, but make sure that it doesn't print the error?
I am hoping that this will be my last question with this - I really appreciate your help with this.
Many thanks,
paulmerton4pope