Basic Usage

Download or build the binary

Download the webp-server-go from release page.

Dump config file

./webp-server -dump-config > config.json

The default config.json may look like this.

{
    "HOST": "127.0.0.1",
    "PORT": "3333",
    "QUALITY": "80",
    "IMG_PATH": "/path/to/pics",
    "EXHAUST_PATH": "/path/to/exhaust",
    "ALLOWED_TYPES": ["jpg","png","jpeg"]
}

Config Example

In the following example, the image path and website URL.

Image Path Website Path
/var/www/img.webp.sh/path/tsuki.jpg https://img.webp.sh/path/tsuki.jpg

The config.json should be like:

IMG_PATH
/var/www/img.webp.sh

EXHAUST_PATH is cache folder for output webp images, with EXHAUST_PATH set to /var/cache/webp in the example above, your webp image will be saved at /var/cache/webp/pics/tsuki.jpg.1582558990.webp.

If you'd like to use a remote backend(such as external Nginx served static site, Aliyun OSS or Tencent COS), please refer to Remote Backend.

Run

./webp-server --config=/path/to/config.json

To keep this program running, refer to Supervisor section.

Nginx Example

This is an example for a typical Wordpress installation.

location ^~ /wp-content/uploads/ {
    proxy_set_header Host $http_host;
    proxy_pass http://127.0.0.1:3333;
}

If you use Caddy, you may refer to 优雅的让 Halo 支持 webp 图片输出.

If there is a CDN in front of your website, please refer to Use with CDN

results matching ""

    No results matching ""