编译实用程序
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如果预编译的实用程序不符合您的需求,您可以自行构建 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。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):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"]],["最后更新时间 (UTC):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,[]]