編譯公用程式
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
如果預先編譯的公用程式不符合需求,您可以自行建構 WebP 公用程式。
使用 Visual C++ 在 Windows 上編譯
從下載清單下載 libwebp-1.6.0.tar.gz
,然後解壓縮內容。
從 libwebp-1.6.0
目錄執行:
nmake /f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output
如要查看其他選項,請執行:
nmake /f Makefile.vc
視目標平台而定,目錄 output\release-static\x86\bin
或 output\release-static\x64\bin
會包含工具 cwebp.exe
和 dwebp.exe
。output\release-static\(x86|x64)\lib
目錄會包含 libwebp
靜態程式庫。
Linux
安裝 libjpeg
、libpng
、libtiff
和 libgif
套件,以便在 JPEG、PNG、TIFF、GIF 和 WebP 圖片格式之間轉換。
套件管理方式會因 Linux 發行版而異。在 Ubuntu 和 Debian 上,下列指令會安裝所需套件:
sudo apt-get install libjpeg-dev libpng-dev libtiff-dev libgif-dev
完成安裝程序 (請參閱下文)。
macOS
MacPorts 是滿足依附元件的便利方式。如已安裝 MacPorts,請直接前往步驟 3。如果沒有,請按照下列步驟操作:
前往 MacPorts
下載網站,下載適用於 macOS 版本的 MacPorts。MacPorts 需要安裝 Xcode。
按照 MacPorts 的指示安裝 MacPorts。
更新 MacPorts:
sudo port selfupdate
安裝 JPEG、PNG、TIFF 和 GIF 依附元件:
sudo port install jpeg libpng tiff giflib
完成安裝程序 (請參閱下文)。
Cygwin
從 Cygwin 網頁下載 setup.exe。
執行 setup.exe,然後繼續安裝。
在「選取套裝方案」畫面中,將下列項目新增至預先選取的套裝方案:
完成安裝程序 (請參閱下文)。
建築物
從下載清單下載 libwebp-1.6.0.tar.gz
。
解壓縮套件。這項操作會建立名為 libwebp-1.6.0/
的目錄:
tar xvzf libwebp-1.6.0.tar.gz
建構 WebP 編碼器 cwebp
和解碼器 dwebp
:
前往 libwebp-1.6.0/
的解壓縮目錄,然後執行下列指令:
cd libwebp-1.6.0
./configure
make
sudo make install
這會建構並安裝 cwebp
和 dwebp
指令列工具,以及 libwebp
程式庫 (動態和靜態)。
這些工具通常會預設安裝在 /usr/local/bin/
下方。本機版本會建構在 examples/
目錄下。
程式庫通常會安裝在 /usr/local/lib/
目錄下。為避免發生執行階段錯誤,請確認 LD_LIBRARY_PATH
環境變數包含這個位置。C 標頭通常會安裝在 /usr/local/include/webp
下方。
如要查看其他選項,請執行:
./configure --help
後續步驟
如要瞭解如何開始轉換圖片,請參閱「使用 WebP」。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-08 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-08 (世界標準時間)。"],[[["\u003cp\u003eThis page provides instructions for building WebP utilities (\u003ccode\u003ecwebp\u003c/code\u003e and \u003ccode\u003edwebp\u003c/code\u003e) from source code if precompiled options are unsuitable.\u003c/p\u003e\n"],["\u003cp\u003eBuilding on Windows involves using Visual C++ with specific commands to compile the utilities and library.\u003c/p\u003e\n"],["\u003cp\u003eFor Unix-like platforms (Linux, macOS, Cygwin), instructions cover installing necessary dependencies before building the WebP tools.\u003c/p\u003e\n"],["\u003cp\u003eThe building process on Unix-like systems involves downloading the source code, configuring, compiling, and installing the utilities and libraries.\u003c/p\u003e\n"],["\u003cp\u003eAfter building the utilities, users can proceed to the "Using WebP" page for image conversion instructions.\u003c/p\u003e\n"]]],["To build WebP utilities: Windows users download `libwebp-1.5.0.tar.gz`, then use `nmake` in the `libwebp-1.5.0` directory to compile, producing `cwebp.exe` and `dwebp.exe` in the output. Unix-like users install `libjpeg`, `libpng`, `libtiff`, and `libgif` packages, then download and extract `libwebp-1.5.0.tar.gz`. Navigate to the directory and run `./configure`, `make`, and `sudo make install` to build and install `cwebp` and `dwebp`.\n"],null,[]]