zoukankan      html  css  js  c++  java
  • 简单小练习_图片压缩工具

    # _*_ coding=utf-8 _*_
    
    from PIL import Image as Img
    from tkinter import *
    from tkinter.filedialog import *
    from tkinter import messagebox
    import os
    
    # ui
    # ui update
    # business
    info = {
        'path':[]
    }
    
    def make_app():
        app = Tk()
        Label(app, text='Image compress tool', font=('Hack',20,'bold')).pack()  
        Listbox(app, name='lbox', bg='#f2f2f2').pack(fill=BOTH, expand=True)
        Button(app, text='open', command=ui_getdata).pack()
        Button(app, text='compresss', command=compress).pack()
        app.geometry('300x400')
        return app
    
    def ui_getdata():
        f_names = askopenfilenames()
        lbox = app.children['lbox']
        info['path'] = f_names
        if info['path']:
            for name in f_names:
                lbox.insert(END, name.split('/')[-1])
            # abc.jpg
    
    def compress():
        for f_path in info['path']:
            output = os.getcwd()+'/'
            name = f_path.split('/')[-1]
            image = Img.open(f_path)
            image.save(output+'c_'+name, quality=60)
            messagebox.showinfo(title='压缩完成',message='压缩完成')
    
    
    
    app = make_app()
    app.mainloop()
  • 相关阅读:
    下载文件
    全局处理程序
    缩略图
    图片
    文件上传
    application用法
    多分辨率的支持
    适用于cocos2dx的编辑器:Texture,Tilemap,Particle,Action,Level etc
    cocos2dx下最大纹理大小取决于平台
    CCLabelTTF 如何支持换行符和换行
  • 原文地址:https://www.cnblogs.com/Erick-L/p/9262847.html
Copyright © 2011-2022 走看看