sizeTuples = [(int(w), int(h)) for w, h in map(lambda wh: wh.split('x'),
    sizeFormats)]

def resizeImages():
    for image in os.listdir(targetPath):
        for resizedWidth, resizedHeight in sizeTuples:
            sourceFilePath = os.path.join(targetPath, image)
imageFileToConvert = Image.open(sourceFilePath)
outputFile = imageFileToConvert.resize((resizedWidth, resizedHeight), Image
    .ANTIALIAS)
outputFile.save(sourceFilePath)
How to loop through one element of a zip() function twice - Python