#! python3 import os,openpyxl,time,pyautogui from PIL import Image startTime = time.localtime() theName = (str(startTime[0]) + str(startTime[1])+ str(startTime[2])) os.chdir('C:\\Users\\Lenovo\\Desktop\\截图和下载\\'+ str(theName)) theChineseDay = str(startTime[0]) + '年' + str(startTime[1]) + '月' + str(startTime[2]) +'日' print(str(theChineseDay) ) print(str(startTime[3]) + ':' + str(startTime[4])) print('输入图片宽度和高度:') width = input() num = input() height = int(width)*9/16 photoNum = int(num)//height + 1 photoToday = Image.open(str(theName)+'.png') for i in range(int(photoNum)-1): m=i*height n= (i+1)*height croppedPh = photoToday.crop((0,m,int(width),n)) croppedPh.save(str(theName)+'BT'+str(i)+'.png') croppedPH = photoToday.crop((0,n,int(width),num-n)) croppedPh.save(str(theName)+'BT'+str(i+1)+'.png') |
|