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

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

  • 相关阅读:
    【就业】腾讯VS百度
    MySQL基础知识
    PHP读取远程文件并保存
    【GTK3.0】背景设置
    【GTK】信号量(signal)大全
    c# 调用win32 api
    PHP写窗体程序
    一个苏州IT人的5年挨踢经历面试篇(之二)
    【c++ Primer 】 4.10复习题 12题(int)、(int&)和(int*)
    线段树技巧
  • 原文地址:https://www.cnblogs.com/111testing/p/6503508.html
Copyright © 2011-2022 走看看