img2webp
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
名稱
img2webp
:從一系列輸入圖片建立動畫 WebP 檔案。
Synopsis
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 至 YUV 轉換程序還要慢。
-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 專案編寫 (其他人也可使用)。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-08 (世界標準時間)。
[null,null,["上次更新時間: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)."]]