Working in jupyter notebook (python), I have 1,478 images that I need to change to one common size. I'm confused as to how to do pick one size that works for all images. I tried the method below, and it reduced a crop of about 12 different sizes to these 4 sizes {(3120, 4160) (2340, 4160) (3264, 2448) (3264, 2441)}
i = 0
for filepath in all_cervix_images['imagepath']:
print(i)
i +=1
width, height = Image.open(filepath).size
#maxsize = 3264, 4160
ratio = min(3264/width, 4160/height)
size = int(width * ratio), int(height * ratio)
try:
img = Image.open(filepath)
img = img.resize(size, Image.ANTIALIAS)
img.save(filepath)
except IOError:
print ("cannot create thumbnail for %s" % filepath)