未经允许,请勿转载!!!!
这次打算先写处理图片的方法,然后再调用方法来运行
下面先写的是处理图片的方法:
# -*- coding: utf-8 -*- import os import matplotlib.pyplot as plt import pytesseract from PIL import Image def picture_operation_copy(path_filename): image = Image.open(path_filename) image.save(path_filename) def picture_operation_delete(path_filename): image = Image.open(path_filename) os.remove(path_filename) def picture_operation_save(path_filename, save_path_filename): image = Image.open(path_filename) image.save(save_path_filename) def picture_operation_show(path_filename): image = Image.open(path_filename) image.show() def picture_operation_close(path_filename): plt.close() #调整图像大小: def picture_operation_changeSize(path_filename): image = Image.open(path_filename) new_image = image.resize((128, 128), Image.BILINEAR) new_image.show() #旋转图像: def picture_operation_rotate(path_filename): image = Image.open(path_filename) rotate_image = image.rotate(45) rotate_image.show()
然后再来调用上面的方法:
# -*- coding: utf-8 -*- from method.picture import * import time picture_operation_copy('C:\Users\chenjia\Desktop\Untitled.jpg') picture_operation_save('C:\Users\chenjia\Desktop\Untitled.jpg', 'C:\Users\chenjia\Desktop\11111111111111111.jpg') picture_operation_show('C:\Users\chenjia\Desktop\11111111111111111.jpg') time.sleep(3) #picture_operation_close('C:\Users\chenjia\Desktop\11111111111111111.jpg') #picture_operation_delete('C:\Users\chenjia\Desktop\11111111111111111.jpg') picture_operation_rotate('C:\Users\chenjia\Desktop\11111111111111111.jpg') time.sleep(3) picture_operation_changeSize('C:\Users\chenjia\Desktop\11111111111111111.jpg') print "well done!!!!!!!!!!"
下面是这两个文件在我的框架里面的位置