zoukankan      html  css  js  c++  java
  • python图片处理(二)

    未经允许,请勿转载!!!!

    这次打算先写处理图片的方法,然后再调用方法来运行

    下面先写的是处理图片的方法:

    # -*- 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!!!!!!!!!!"

    下面是这两个文件在我的框架里面的位置

  • 相关阅读:
    Java中使用Base64编码URL
    JSON Web Token (JWT)入门学习
    1047. 删除字符串中的所有相邻重复项
    1021. 删除最外层的括号
    使用shell获取随机端口<帮你解决端口的占用烦恼>
    初始化一个vue项目并生成完整的目录结构
    mysql-常用字符函数
    设计模式-单例模式-饿汉和懒汉
    Java-指令的重排序
    Java-反射类加载到内存分析
  • 原文地址:https://www.cnblogs.com/111testing/p/6503508.html
Copyright © 2011-2022 走看看