The Image2webp project is an application written with golang that supports real-time transcoding of multiple image formats into webp images.
Currently support JPG
, JPEG
, PNG
, BMP
, GIF
these formats into Webp
format.
'Webp' format can significantly reduce the size of the picture without affecting the picture quality, so as to improve the speed of network transmission, save bandwidth traffic resources.
This project also supports webp format thumbnail function, is also real-time transcoding, can be configured to the existing server without invasion, only need to do some forwarding in nginx, do not change any other logic.
The best realization of this project is to start this service in the picture server and configure forwarding in nginx or other web servers,
Just match the url format ^(.+)_webp(_(\d+)_(\d+)(.*))?
to forward to the image2webp program and output the webp image.
If it is the front end to access the picture, when the request volume is large, this real-time transcoding method will cause CPU performance, so for the large request volume, please see, before you must use the CDN file.
Set the CDN image cache expiration date a little longer, the service is only used back to the source, that is perfect.
Compilation is very simple, make sure your go version is 1.16
and above, and turn on support for mod
.
Execute the make
command and it will compile automatically.
Of course, you can also manually execute the full path compiler command.
$ go build -v -o image2webp
After compiling successfully, you can execute
$ ./image2webp start --config=./config.json
To start it.
config.json
Is in json format.
image2webp
deployment is also very convenient, just need to put the compiled binaries directly on the server to run,
Then configure the front - end proxy, you can refer to nginx.conf
.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。