mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 13:42:02 +08:00
Push README.md
Bump version.
This commit is contained in:
parent
200a52de2a
commit
9e6f648cc4
66
README.md
66
README.md
@ -56,39 +56,7 @@ Create a `config.json` as follows to face your need, default convert quality is
|
||||
}
|
||||
```
|
||||
## 3. Run
|
||||
Run the binary like this: `./webp-server --config /path/to/config.json`, for prefetch mode, add `--prefech`.
|
||||
|
||||
> Prefetch mode will pre-convert all the images in the `IMG_PATH` on initial start up.
|
||||
|
||||
### screen or tmux
|
||||
Use `screen` or `tmux` to avoid being terminated. Let's take `screen` for example
|
||||
```
|
||||
screen -S webp
|
||||
./webp-server --config /path/to/config.json
|
||||
```
|
||||
(Use Ctrl-A-D to detach the `screen` with `webp-server` running.)
|
||||
### systemd
|
||||
Don't worry, we've got you covered!
|
||||
|
||||
Download `webp-server` to `/opt/webps/webp-server`, and create a config file to `/opt/webps/config.json`, then,
|
||||
|
||||
```shell script
|
||||
cp webps.service /lib/systemd/system/
|
||||
systemctl daemon-reload
|
||||
systemctl enable webps.service
|
||||
systemctl start webps.service
|
||||
```
|
||||
## 4. Nginx proxy_pass
|
||||
Let Nginx to `proxy_pass http://localhost:3333/;`, and your webp-server is on-the-fly
|
||||
### WordPress example
|
||||
```
|
||||
location ^~ /wp-content/uploads/ {
|
||||
proxy_pass http://127.0.0.1:3333;
|
||||
}
|
||||
```
|
||||
|
||||
## Advanced usage
|
||||
### show help
|
||||
```
|
||||
./webp-server --help
|
||||
Usage of ./webp-server:
|
||||
@ -108,8 +76,7 @@ Usage of ./webp-server:
|
||||
use prefork
|
||||
```
|
||||
### Prefetch
|
||||
Prefetch will convert all your images to webp. Don't worry, Webp server will start,
|
||||
you don't have to wait until prefetch completes.
|
||||
Prefetch will convert all your images to webp. Don't worry, WebP Server will start, you don't have to wait until prefetch completes.
|
||||
```
|
||||
./webp-server -prefetch
|
||||
```
|
||||
@ -122,7 +89,7 @@ By default, it will utilize all your CPU cores.
|
||||
### dump config.json
|
||||
The standard `config.json` will show on your screen. You many want to use `>` to redirect to a file.
|
||||
```
|
||||
./webp-server -dump-config
|
||||
./webp-server -dump-config > config.json
|
||||
```
|
||||
### dump systemd service file
|
||||
The standard systemd service file will show on your screen. You many want to use `>` to redirect to a file.
|
||||
@ -131,6 +98,35 @@ The standard systemd service file will show on your screen. You many want to use
|
||||
./webp-server -dump-systemd
|
||||
```
|
||||
|
||||
### screen or tmux
|
||||
Use `screen` or `tmux` to avoid being terminated. Let's take `screen` for example
|
||||
```
|
||||
screen -S webp
|
||||
./webp-server --config /path/to/config.json
|
||||
```
|
||||
(Use Ctrl-A-D to detach the `screen` with `webp-server` running.)
|
||||
### systemd
|
||||
Don't worry, we've got you covered!
|
||||
|
||||
Download `webp-server` to `/opt/webps/webp-server`, and create a config file to `/opt/webps/config.json`, then,
|
||||
|
||||
```shell script
|
||||
./webp-server -dump-systemd > /lib/systemd/system/webp-server.service
|
||||
systemctl daemon-reload
|
||||
systemctl enable webps.service
|
||||
systemctl start webps.service
|
||||
```
|
||||
## 4. Nginx proxy_pass
|
||||
Let Nginx to `proxy_pass http://localhost:3333/;`, and your webp-server is on-the-fly
|
||||
### WordPress example
|
||||
```
|
||||
location ^~ /wp-content/uploads/ {
|
||||
proxy_pass http://127.0.0.1:3333;
|
||||
}
|
||||
```
|
||||
If you use Caddy, you may refer to [优雅的让 Halo 支持 webp 图片输出](https://halo.run/archives/halo-and-webp).
|
||||
## Advanced usage
|
||||
|
||||
## Build your own binaries
|
||||
Install latest version of golang, enable go module, clone the repo, and then...
|
||||
```shell script
|
||||
|
@ -4,11 +4,5 @@
|
||||
"QUALITY": "80",
|
||||
"IMG_PATH": "/path/to/pics",
|
||||
"EXHAUST_PATH": "",
|
||||
"ALLOWED_TYPES": [
|
||||
"jpg",
|
||||
"png",
|
||||
"jpeg",
|
||||
"bmp",
|
||||
"gif"
|
||||
]
|
||||
"ALLOWED_TYPES": ["jpg","png","jpeg","bmp","gif"]
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
[Unit]
|
||||
Description=WebP Server
|
||||
Documentation=https://github.com/n0vad3v/webp_server_go
|
||||
Description=WebP Server Go
|
||||
Documentation=https://github.com/webp-sh/webp_server_go
|
||||
After=nginx.target
|
||||
|
||||
[Service]
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"golang.org/x/image/bmp"
|
||||
"image"
|
||||
"image/gif"
|
||||
"image/jpeg"
|
||||
@ -22,6 +21,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/image/bmp"
|
||||
|
||||
"github.com/chai2010/webp"
|
||||
"github.com/gofiber/fiber"
|
||||
)
|
||||
@ -35,7 +36,7 @@ type Config struct {
|
||||
ExhaustPath string `json:"EXHAUST_PATH"`
|
||||
}
|
||||
|
||||
const version = "0.0.3"
|
||||
const version = "0.0.4"
|
||||
|
||||
var configPath string
|
||||
var prefetch bool
|
||||
@ -48,15 +49,15 @@ const sampleConfig = `
|
||||
"HOST": "127.0.0.1",
|
||||
"PORT": "3333",
|
||||
"QUALITY": "80",
|
||||
"IMG_PATH": "/Users/benny/goLandProject/webp_server_go/pics",
|
||||
"IMG_PATH": "/path/to/pics",
|
||||
"EXHAUST_PATH": "",
|
||||
"ALLOWED_TYPES": ["jpg", "png", "jpeg", "bmp", "gif"]
|
||||
"ALLOWED_TYPES": ["jpg","png","jpeg","bmp","gif"]
|
||||
}
|
||||
`
|
||||
const sampleSystemd = `
|
||||
[Unit]
|
||||
Description=WebP Server
|
||||
Documentation=https://github.com/n0vad3v/webp_server_go
|
||||
Documentation=https://github.com/webp-sh/webp_server_go
|
||||
After=nginx.target
|
||||
|
||||
[Service]
|
||||
|
Loading…
x
Reference in New Issue
Block a user