Skip to content
/ twebp Public

图片转换webp格式,支持gif转换保留动画,可以命令行使用,也可以作为web服务使用

Notifications You must be signed in to change notification settings

fish2018/twebp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

twebp

独立的 WebP 图片批量转换工具,既可 CLI 使用也可启动 Web 服务。

编译

git clone <repo> && cd twebp
go mod download
go build ./cmd/webptool

CLI 参数

webptool [options]

  -img string         单张图片路径
  -dir string         批量处理目录
  -json string        接受 JSON 数组或 @file.json
  -recursive bool     目录模式是否递归(默认 true)
  -ratio bool         单图是否保持原宽高比(默认 true)
  -w int              最大宽度(0=自动)
  -h int              最大高度(0=自动)
  -keep bool          转换后是否保留原图(默认 true)
  -webp bool          输出是否强制使用 .webp 扩展
  -concurrency int    并发数(默认 4)
  -sync bool          目录模式使用同步处理
  -assets string      自定义 assets 根目录
  -web bool           启动 Web 服务
  -web-port int       Web 服务端口(默认 8090)
  -web-output string  Web 输出目录(默认 web_output)

CLI 示例

# 单张图片并输出 .webp
./webptool -img poster.jpg -webp

# 批量目录,递归处理,保留原图
./webptool -dir ./pictures -recursive -keep

# JSON 列表(文件内容示例:["imgs/1.jpg","/home/user/a.png"])
./webptool -json '@/tmp/list.json' -concurrency 8

Web 模式

./webptool -web -web-port 8090 -web-output web_output

浏览器访问 http://localhost:8090,支持:

  • 选择文件或整个目录,多次追加;
  • 设置最大宽高、宽高比(常见比例或自定义分辨率)、并发数、输出扩展名;
  • 转换完成后支持单个下载或 ZIP 打包下载全部结果(存储在服务器 web-output 目录中)。

About

图片转换webp格式,支持gif转换保留动画,可以命令行使用,也可以作为web服务使用

Resources

Stars

Watchers

Forks

Languages