Git Product home page Git Product logo

fast2webp's Introduction

fast2webp

Travis build

PyPI version

Python version

一个将 PNG、JPG、JPEG、BMP、GIF 等格式的图像文件批量 (递归) 转换为 webp 格式的 Python 脚本

可以设定压缩级别 (0 ~ 100),数字越大品质越好。支持无损压缩。支持多线程。

可以在 GNU/Linux 上运行,Mac OS 估计也可以 (没测试过),Windows 上可能要修改一下才能用 (主要是目录地址中 /\ 的区别)

突然发现 webp 的工具包中有一个叫 img2webp 的工具 (没用过所以不知道QAQ),为了避免冲突现将项目改名为 fast2webp _(:з」∠)_

依赖

  • Python3
  • webp

安装

sudo pip3 install fast2webp

使用

fast2webp [options] <value>

截图

image

参数 (options)

usage: fast2webp [-h] [-i <dir>] [-o <dir>] [-q <int> | -lossless][-t <int>] 
                [-only {png,jpg,bmp,gif}] [-enable_gif] [-uncopy]

-i <dir> .......... 需要转换的文件所在的目录,会递归进行转换  (默认:.[当前目录])
-o <dir> .......... *.webp 文件的输出目录,输出目录结构与输入目录保持一致 (默认:./output)
                    如果输出目录不存则会按照给定的路径新建文件夹
                    如果缺省,则会在当前目录中新建并输出到目录 'output'
-q <int> .......... 与 'cwebp' 中相同;表示压缩的程度 (0 ~ 100),数字越大品质越好 (默认:80)
-t <int> .......... 线程池中线程的个数;数字越大转换速度越快。当然,也更吃资源 (默认:10)
-lossless ......... 与 'cwebp' 中相同;无损压缩
-only <value> ..... 只执行某单一任务 (可接受的值有:png、jpg、bmp、gif)
                    例如:-only png 表示只转换输入目录中的 png 文件为到输出目录
-enable_gif ....... 将 gif 转为 webp (默认情况下会跳过 gif 文件)
                    转换 gif 文件比较吃资源,慎用
                    转换 gif 文件不支持无损压缩,此时 -lossless = -q 100
-uncopy ........... 默认情况下会将非图片文件复制到输出目录中,使用参数 -uncopy 关闭这一特性
                    (*.webp 和 *.gif 仍会被复制)
-h ................ 展示帮助信息

TODO

  • 支持 Windows
  • 支持更多的参数

fast2webp's People

Contributors

mogeko avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.