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

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

  • 相关阅读:
    检查 Linux 服务器性能
    openssl、x509、crt、cer、key、csr、ssl、tls 这些都是什么鬼?
    Jenkins+ Xcode+ 蒲公英 实现IOS自动化打包和分发
    如何在 Linux 上录制你的终端操作
    Swift 开源 Linux Ubuntu Install
    SCP 命令
    ubuntu openfire Server install
    git 和 svn 的比较
    implicitly declaring function 'malloc' with type void *(unsigned long ) 错误 解决
    python 使用缓存加快运算
  • 原文地址:https://www.cnblogs.com/111testing/p/6503508.html
Copyright © 2011-2022 走看看