Skip to content

loveczp/fqimg

Repository files navigation

FQimg

fqimg playground

http://loveczp.github.io/fqimg/

Chinese Version document

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

examples

Document

  • install and run
    go get github.com/loveczp/fqimg
    then run fqimg with following command

    fqimg -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 server

    curl -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 is cmd ,which has no paramter, or cmd=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.

command list

command name command format example result
fit fit=width_height
fit=width_height_filter
fit=100_300
fit=100_300_box
fit mod cut
fill fill=width_height
fill=width_height_filter
fill=width_height_filter_anchor
fill=100_300
fill=100_300_box
fill=100_300_box_top
fill mod cut
resize resize=width_height
resize=width_height_filter
resize=100_300
resize=100_300_box
resize mod cut
gamma gamma
gamma=stength
gamma
gamma=234
contrast contrast
contrast=stength
contrast
contrast=20
increase the contrast
brightness brightness
brightness=stength
brightness
brightness=0.5
increase the brightness
grayscale grayscale grayscale
grayscale the image
invert invert invert
invert the iamge
blur blur
blur=stength
blur
blur=3.5
blur the image
sharpen sharpen
sharpen=stength
sharpen
sharpen=3.5
sharpen the image
rotate90 rotate90 rotate90
rotate 90 degree
rotate180 rotate180 rotate180
rotate 180 degree
rotate270 rotate270 rotate270
rotate 270 degree
flipH flipH flipH
flip horizontally
flipV flipV flipV
flip vertically
webp webp
webp=quality
webp
webp=80
output webp format image with 80% quality
jpeg jpeg
jpeg=quality
jpeg
jpeg=80
output jpeg format image with 80% quality
png png png
output png format
gif gif
gif=num
num is number of color
png
png=128
output png format with 128 color
mark mark=id
mark=id_offx_offy
mark=id_offx_offy_offp
mark=id_offx_offy_offp_alpha
water mark
id is the image key set in the config file
mark=a
mark=a_10_10
mark=a_10_10_lu
mark=a_10_10_lu_255