คอมไพล์ยูทิลิตี
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
หากยูทิลิตีที่คอมไพล์ล่วงหน้าไม่เหมาะกับความต้องการของคุณ
คุณก็สร้างยูทิลิตี WebP ด้วยตนเองได้
การคอมไพล์ใน Windows ด้วย Visual C++
ดาวน์โหลด 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
static
library
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
ดาวน์โหลด setup.exe จากหน้าเว็บ Cygwin
เรียกใช้ setup.exe และดำเนินการติดตั้ง
ในหน้าจอเลือกแพ็กเกจ ให้เพิ่มรายการต่อไปนี้ลงในแพ็กเกจที่เลือกไว้ล่วงหน้า
libjpeg-devel
, libpng-devel
, libtiff-devel
และ libgif-devel
gcc
, make
และ automake
(สำหรับแพ็กเกจการสร้าง)
ติดตั้งให้เสร็จสมบูรณ์ (ดูด้านล่าง)
อาคาร
ดาวน์โหลด libwebp-1.6.0.tar.gz
จากรายการดาวน์โหลด
คลายการบีบอัดแพ็กเกจ ซึ่งจะสร้างไดเรกทอรีชื่อ libwebp-1.6.0/
ดังนี้
tar xvzf libwebp-1.6.0.tar.gz
สร้างโปรแกรมเข้ารหัส cwebp
และโปรแกรมถอดรหัส dwebp
WebP โดยทำดังนี้
ไปที่ไดเรกทอรีที่แยก 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 Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-08 UTC
[null,null,["อัปเดตล่าสุด 2025-08-08 UTC"],[[["\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,["# Compiling the Utilities\n\nIf the [precompiled utilities](/speed/webp/docs/precompiled) don't suit your\nneeds, you can build the WebP utilities yourself.\n\nCompiling on Windows with Visual C++\n------------------------------------\n\n1. Download `libwebp-1.6.0.tar.gz` from the [downloads list](https://storage.googleapis.com/downloads.webmproject.org/releases/webp/index.html)\n and extract its contents.\n\n2. From the `libwebp-1.6.0` directory, run:\n\n nmake /f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output\n\n To see additional options, run: \n\n nmake /f Makefile.vc\n\n3. The directory `output\\release-static\\x86\\bin` or\n `output\\release-static\\x64\\bin` will contain the tools `cwebp.exe` and\n `dwebp.exe` depending on the platform being targeted. The directory\n `output\\release-static\\(x86|x64)\\lib` will contain the `libwebp` static\n library.\n\nCompiling on Unix-like Platforms\n--------------------------------\n\n### Preparing the Platform\n\n#### Linux\n\n1. Install the `libjpeg`, `libpng`, `libtiff` and `libgif` packages, needed to\n convert between JPEG, PNG, TIFF, GIF and WebP image formats.\n\n Package management varies by Linux distribution. On Ubuntu and Debian, the\n following command will install the needed packages: \n\n sudo apt-get install libjpeg-dev libpng-dev libtiff-dev libgif-dev\n\n2. Complete the installation ([see below](#building)).\n\n#### macOS\n\nMacPorts is a convenient way to satisfy dependencies. If you already have\nMacPorts installed, go directly to Step 3. Otherwise, follow these steps:\n\n1. Download MacPorts for your macOS version from the MacPorts\n [downloads site](https://distfiles.macports.org/MacPorts). MacPorts requires\n the installation of\n [Xcode](https://developer.apple.com/xcode/).\n\n2. Install MacPorts following the MacPorts\n [directions](https://guide.macports.org/).\n\n3. Update MacPorts:\n\n sudo port selfupdate\n\n4. Install the JPEG, PNG, TIFF and GIF dependencies:\n\n sudo port install jpeg libpng tiff giflib\n\n5. Complete the installation ([see below](#building)).\n\n#### Cygwin\n\n1. Download setup.exe from the [Cygwin web page](https://www.cygwin.com).\n\n2. Run setup.exe and proceed through the installation.\n\n3. At the **Select Packages** screen, add to the pre-selected packages the\n following:\n\n - `libjpeg-devel`, `libpng-devel`, `libtiff-devel` and `libgif-devel`\n\n - `gcc`, `make` and `automake` (for building packages)\n\n4. Complete the installation ([see below](#building)).\n\n### Building\n\n1. Download `libwebp-1.6.0.tar.gz` from the\n [downloads list](https://storage.googleapis.com/downloads.webmproject.org/releases/webp/index.html).\n\n2. Untar or unzip the package. This creates a directory named `libwebp-1.6.0/`:\n\n tar xvzf libwebp-1.6.0.tar.gz\n\n3. Build WebP encoder `cwebp` and decoder `dwebp`:\n\n Go to the directory where `libwebp-1.6.0/` was extracted to\n and run the following commands: \n\n cd libwebp-1.6.0\n ./configure\n make\n sudo make install\n\n This builds and installs the `cwebp` and `dwebp` command line tools, along\n with the `libwebp` libraries (dynamic and static).\n\n These tools are usually installed under `/usr/local/bin/` by default. The\n local versions are built under the `examples/` directory.\n\n The library will usually be installed under the `/usr/local/lib/` directory.\n To avoid run-time errors, make sure that your `LD_LIBRARY_PATH` environment\n variable includes this location. The C headers are typically installed under\n `/usr/local/include/webp`.\n\n To see additional options, run: \n\n ./configure --help\n\nWhat Next?\n----------\n\nGo to [Using WebP](/speed/webp/docs/using) for instructions on how to start\nconverting your images."]]