http://loveczp.github.io/fqimg/
FQimg is a image server powered by Golang
features:
- dynamicly process the images。The url of the image can accept commands and parameters, by which we can crop, fill, grayscale,etc the image in real time.
- chain mode。commands can be chained together like Unix pipe.
- high performance. Because of the excelence of Golang, the FQimg server has very low RAM and CPU consumption.
- support webp webp image format. Webp is better than jpeg, it has the lower size on the same image quality. For mobile application, it is very important.
- simple to deploy. FQimg is an executalbe binary file, don't need to install any extra library.
- support multiple image format, such as jpeg, gif,bmp, webp. Also support the quality parameter for each format.
- FQimg has cache mechanism, repeatly requested images are cached. This feature can tremendously increase the performance.
- support the uploading Ip control. Only designated IPs are allowed to upload image.
- CORS upload support. This is important for web application.
- support HTTPS
- support two storage type. 1. local file system,2. seaweeddfs
-
original image https://fqimg.com/get/0fd5e7521b8e91e207a7552fc3113e87
-
dynamic cut example
fill=400_400 command will dynamicly cut the image in to 400*400 image, the height and width can be dynamicly set at one's will. https://fqimg.com/get/0fd5e7521b8e91e207a7552fc3113e87?fill=400_400 -
chain mode example
fit=200_300&grayscale is two chained command, fit and grascale. the server would first cut the image by 200*300, and then grayscale the product of the first step. Surely we can chain more command.
https://fqimg.com/get/0fd5e7521b8e91e207a7552fc3113e87?fit=200_300&grayscale -
output webp format
50 is the quality parameter of webp command
https://fqimg.com/get/0fd5e7521b8e91e207a7552fc3113e87?webp=50
-
install and run
go get github.com/loveczp/fqimg
then run fqimg with following commandfqimg -c=path/to/config/file
attention:
- on window, we should first install tdm-gcc, or FQimg can not be compiled. Because the webp library is a C library.
- go version should be greater than 1.8
-
image upload
we can use the curl command to post a image to the servercurl -F "file=@xxxxx.jpg" "http://fqimg.com/put"
change the xxx.jpg and fqimg.com according to your circumstance.
["https://fqimg.com/get/0fd5e7521b8e91e207a7552fc3113e87"]
when local storage is used, the last part of the URL is the of MD5 value of the image,FQimg use this value to pinpoint the image in file system.Then we can get our image through the returned URL
https://fqimg.com/get/0fd5e7521b8e91e207a7552fc3113e87 -
image manipulation
Each manipulation of the image has an corresponding command. Each command has Zero or multiple parameters. the format of the command iscmd
,which has no paramter, orcmd=a_b_c
, which has three parameters a,b,c. The command attach to the rear of the URL as the standard url parameter.
Example: https://fqimg.com/get/0fd5e7521b8e91e207a7552fc3113e87?fit=200_300&grayscale
The above URL has two cmd 1,fit=200_300
2,grayscale
two commands are connected by&
symbol.