start of the programwe've made it easy to change the program later say the logo that you're adding isn' the cat iconor say you're reducing the output imageslargest dimension to something other than pixels with these constants at the start of the programyou can just open the codechange those values onceand you're done (or you can make it so that the values for these constants are taken from the command line arguments without these constantsyou' instead have to search the code for all instances of and 'catlogo pngand replace them with the values for your new project in shortusing constants makes your program more generalized the logo image object is returned from image open( for readabilitylogowidth and logoheight are assigned to the values from logoim size the rest of the program is skeleton of todo comments for now step loop over all files and open images now you need to find every png file and jpg file in the current working directory you don' want to add the logo image to the logo image itselfso the program should skip any image with filename that' the same as logo_filename add the following to your code#python resizeandaddlogo py resizes all images in current working directory to fit in squareand adds catlogo png to the lower-right corner import os from pil import image --snip-os makedirs('withlogo'exist_ok=trueloop over all files in the working directory for filename in os listdir(') if not (filename endswith(png'or filename endswith(jpg')or filename =logo_filenamew continue skip non-image files and the logo file itself im image open(filenamewidthheight im size --snip-firstthe os makedirs(call creates withlogo folder to store the finished images with logosinstead of overwriting the original image files the exist_ok=true keyword argument will keep os makedirs(from raising an exception if withlogo already exists while looping through all the files in the working directory with os listdir('uthe long if statement checks whether each filename doesn' end with png or jpg if so--or if the file is the logo image itself--then the loop should skip it and use continue to go to the next file if filename does end with pngor jpg(and isn' the logo file)you can open it as an image object and set width and height