From 96802dc3bc6e6e3ff6f6bba84d4703edb7881fb6 Mon Sep 17 00:00:00 2001 From: Nova Kwok Date: Mon, 15 May 2023 21:43:29 +0800 Subject: [PATCH] Update README (#195) --- README.md | 9 +++++++-- encoder.go | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bd89edf..5785c03 100644 --- a/README.md +++ b/README.md @@ -66,10 +66,15 @@ The default `config.json` may look like this. "IMG_PATH": "/path/to/pics", "EXHAUST_PATH": "/path/to/exhaust", "ALLOWED_TYPES": ["jpg","png","jpeg","bmp"], - "ENABLE_AVIF": false + "ENABLE_AVIF": false, + "ENABLE_EXTRA_PARAMS": false } ``` -> AVIF support is disabled by default as converting images to AVIF is CPU consuming. + +> `ENABLE_AVIF` means AVIF support, it's disabled by default as converting images to AVIF is CPU consuming. +> +> `ENABLE_EXTRA_PARAMS` means whether to enable Extra Parameters, basically it allows you to do some transform on images like `https://img.webp.sh/path/tsuki.jpg?width=20`, you can find more info on [Extra Parameters](https://docs.webp.sh/usage/extra-params/) page. + #### Config Example diff --git a/encoder.go b/encoder.go index 69f2be0..7476e39 100644 --- a/encoder.go +++ b/encoder.go @@ -73,7 +73,7 @@ func convertImage(raw, optimized, itype string, extraParams ExtraParams) error { // delete the old converted pic and convert a new one. // optimized: /home/webp_server/exhaust/path/to/tsuki.jpg.1582558990.webp // we'll delete file starts with /home/webp_server/exhaust/path/to/tsuki.jpg.ts.itype - // If contain extraParams like tsuki.jpg?width=200, exhaust path will be /home/webp_server/exhaust/path/to/tsuki.jpg.1582558990.webp?width=200 + // If contain extraParams like tsuki.jpg?width=200, exhaust path will be /home/webp_server/exhaust/path/to/tsuki.jpg.1582558990.webp_width=200 s := strings.Split(path.Base(optimized), ".") pattern := path.Join(path.Dir(optimized), s[0]+"."+s[1]+".*."+s[len(s)-1])