img2webp
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
名称
img2webp
- 通过一系列输入图片创建动画 WebP 文件。
摘要
img2webp [file_options] [[frame_options] frame_file]...
img2webp argument_file_name
说明
img2webp
使用动画 WebP 格式压缩一系列图片。输入图片可以是 PNG、JPEG、TIFF 或 WebP。如果将单个文件名(不以字符“-”开头)作为参数提供,则命令行参数实际上是从此文件中进行分词的。这样,您就可以轻松编写脚本或使用大量参数。
文件级选项
文件级选项会在压缩流程开始(读取输入帧之前)应用。
-o string
- 指定输出 WebP 文件的名称。
-min_size
- 对图片进行编码,以实现最小尺寸。这会停用关键帧插入,并选择可使每个帧的输出最小的参数。它默认使用无损压缩,但可以与
-q
、-m
、-lossy
或 -mixed
选项组合使用。
-kmin int
-kmax int
- 指定输出动画中连续关键帧(可独立解码的帧)之间的最小和最大距离。该工具会根据需要将一些关键帧插入输出动画中,以满足此条件。
-mixed
- 混合压缩模式:通过启发词语为每个帧选择有损或无损压缩,优化图像压缩。此全局选项会停用本地选项
-lossy
和 -lossless
。
-near_lossless int
- 指定近乎无损图片预处理级别。此选项会调整像素值以提高压缩率,但对视觉质量的影响微乎其微。它会自动触发无损压缩模式。范围为 0(最大预处理)到 100(无预处理,默认值)。典型值约为 60。请注意,使用
-q 100
的损失式编码有时可以获得更好的结果。
-sharp_yuv
- 使用更准确、更清晰的 RGB 向 YUV 转换。请注意,此过程的速度比默认的“快速”RGB 转换慢一些。
-loop int
- 指定动画应循环的次数。使用
0
表示“无限循环”。
-v
- 提供更多详细信息。
-h, -help
- 简短的用法摘要。
-version
- 输出所用相关库的版本号。
每帧选项
每帧选项会应用于命令行中作为参数的后续图片。在每张特定输入图片之前,可以对它们进行任意次数的修改。
-d int
- 以毫秒为单位指定图片时长。
-lossless, -lossy
- 使用无损或有损压缩模式压缩下一个图片。默认模式是无损模式。
-q float
- 指定介于 0 到 100 之间的压缩系数。默认值为 75。
-m int
- 指定要使用的压缩方法。此参数用于控制编码速度与压缩文件大小和质量之间的权衡。可能的值范围是 0 到 6。默认值为 4。使用较高值时,编码器会花更多时间检查其他编码可能性并确定质量提升幅度。值越低,处理时间越短,但文件大小越大,压缩质量越低。
错误
示例
img2webp -loop 2 in0.png -lossy in1.jpg -d 80 in2.tiff -o out.webp
作者
img2webp
是 libwebp
的一部分,由 WebP 团队编写。最新的源代码树可从 https://chromium.googlesource.com/webm/libwebp 获取
本手册页由 Pascal Massimino pascal.massimino@gmail.com 为 Debian 项目撰写(其他人也可以使用)。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-08。
[null,null,["最后更新时间 (UTC):2025-08-08。"],[[["\u003cp\u003e\u003ccode\u003eimg2webp\u003c/code\u003e is a command-line tool that creates animated WebP files from a sequence of PNG, JPEG, TIFF, or WebP images.\u003c/p\u003e\n"],["\u003cp\u003eIt offers various options for controlling compression, loop behavior, key frame insertion, and image quality.\u003c/p\u003e\n"],["\u003cp\u003eUsers can specify file-level options that apply to the entire animation and per-frame options for individual images.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eimg2webp\u003c/code\u003e supports both lossy and lossless compression modes and allows fine-tuning of compression parameters for optimal file size and quality.\u003c/p\u003e\n"],["\u003cp\u003eDetailed usage instructions, including options and examples, are provided in the documentation.\u003c/p\u003e\n"]]],["`img2webp` creates animated WebP files from image sequences (PNG, JPEG, TIFF, WebP). Key actions include setting file-level options like output filename (`-o`), minimum size (`-min_size`), keyframe distances (`-kmin`, `-kmax`), compression mode (`-mixed`, `-near_lossless`, `-sharp_yuv`), and loop count (`-loop`). Per-frame options include duration (`-d`), compression type (`-lossless`, `-lossy`), quality (`-q`), and method (`-m`). You can report bugs or submit patches at the provided links.\n"],null,["# img2webp\n\nName\n----\n\n`img2webp` -- Create animated WebP file from a sequence of input images.\n\nSynopsis\n--------\n\n`img2webp [file_options] [[frame_options] frame_file]...` \n\n`img2webp argument_file_name`\n\nDescription\n-----------\n\n`img2webp` compresses a sequence of images using the animated WebP format. Input\nimages can either be PNG, JPEG, TIFF or WebP. If a single file name (not\nstarting with the character '-') is supplied as the argument, the command line\narguments are actually tokenized from this file. This allows for easy scripting\nor using a large number of arguments.\n\nFile-level Options\n------------------\n\nThe file-level options are applied at the beginning of the compression process,\nbefore the input frames are read.\n\n`-o string`\n: Specify the name of the output WebP file.\n\n`-min_size`\n: Encode images to achieve smallest size. This disables key frame insertion\n and picks the parameters resulting in the smallest output for each frame. It\n uses lossless compression by default, but can be combined with `-q`, `-m`,\n `-lossy` or `-mixed` options.\n\n`-kmin int` \n`-kmax int`\n: Specify the minimum and maximum distance between consecutive key frames\n (independently decodable frames) in the output animation. The tool will\n insert some key frames into the output animation as needed so that this\n criteria is satisfied.\n\n`-mixed`\n: Mixed compression mode: optimize compression of the image by picking either\n lossy or lossless compression for each frame heuristically. This global\n option disables the local option `-lossy` and `-lossless`.\n\n`-near_lossless int`\n: Specify the level of near-lossless image preprocessing. This option adjusts\n pixel values to help compressibility, but has minimal impact on the visual\n quality. It triggers lossless compression mode automatically. The range is 0\n (maximum preprocessing) to 100 (no preprocessing, the default). The typical\n value is around 60. Note that lossy with `-q 100` can at times yield better\n results.\n\n`-sharp_yuv`\n: Use more accurate and sharper RGB-\\\u003eYUV conversion. Note that this process is\n slower than the default 'fast' RGB-\\\u003eYUV conversion.\n\n`-loop int`\n: Specifies the number of times the animation should loop. Using `0` means\n 'loop indefinitely'.\n\n`-v`\n: Be more verbose.\n\n`-h, -help`\n: A short usage summary.\n\n`-version`\n: Print the version numbers of the relevant libraries used.\n\nPer-frame Options\n-----------------\n\nThe per-frame options are applied for the images following as arguments in the\ncommand line. They can be modified any number of times preceding each particular\ninput image.\n\n`-d int`\n: Specify the image duration in milliseconds.\n\n`-lossless, -lossy`\n: Compress the next image(s) using lossless or lossy compression mode. The\n default mode is lossless.\n\n`-q float`\n: Specify the compression factor between 0 and 100. The default is 75.\n\n`-m int`\n: Specify the compression method to use. This parameter controls the trade off\n between encoding speed and the compressed file size and quality. Possible\n values range from 0 to 6. Default value is 4. When higher values are used,\n the encoder will spend more time inspecting additional encoding\n possibilities and decide on the quality gain. Lower value can result in\n faster processing time at the expense of larger file size and lower\n compression quality.\n\nBugs\n----\n\n- Please report all bugs to the issue tracker: \u003chttps://issues.webmproject.org\u003e\n\n- Patches welcome! See this page to get started: \u003chttps://www.webmproject.org/code/contribute/submitting-patches/\u003e\n\nExample\n-------\n\n img2webp -loop 2 in0.png -lossy in1.jpg -d 80 in2.tiff -o out.webp\n\nAuthors\n-------\n\n`img2webp` is a part of `libwebp` and was written by the WebP team. The latest\nsource tree is available at \u003chttps://chromium.googlesource.com/webm/libwebp\u003e\n\nThis manual page was written by Pascal Massimino [pascal.massimino@gmail.com](mailto:pascal.massimino@gmail.com)\nfor the Debian project (and may be used by others)."]]