from PIL import ImageColor as ic
from PIL import Image
import os,sys
def resizeImage(imgName,maxSize,newName):
image = Image.open(imgName)
width,height = image.size
nwidth,nheight = maxSize,int(height * maxSize / width)
if width < height: nheight,nwidth = maxSize,int(width * maxSize / height)
nimage = image.resize((nwidth,nheight))
imgSecName = imgName[imgName.rfind("."):]
nimage.save(newName + imgSecName)
def main():
imgList,imgList2 = os.listdir(),[]
imgList.remove(sys.argv[0])
for it in imgList: imgList2.append((it,os.path.getmtime(it)))
imgList2.sort(key=lambda x:x[1])
for idx,it in enumerate(imgList2): resizeImage(it[0],4000,str(idx+1) + "2")
if __name__ == '__main__':
main()