项目作者: simukti

项目描述 :
[POC] Go http server for basic image processing based on fasthttp, and bimg (extending libvips).
高级语言: Shell
项目地址: git://github.com/simukti/imageserver.git
创建时间: 2017-03-19T03:34:32Z
项目社区:https://github.com/simukti/imageserver

开源协议:Other

下载


README

Imageserver is a simple Go http server for basic image processing based on fasthttp, and bimg (extending libvips).

REQUIREMENTS

On OSX:

  1. brew update
  2. brew install vips --with-webp

On Linux:

  1. sudo ./vips_install.sh

Tested On:

  1. Machine: MacBook Pro (Retina, 15-inch, Mid 2014)
  2. Processor: 2,5 GHz Intel Core i7
  3. Memory: 16 GB 1600 MHz DDR3
  4. $ uname -v
  5. Darwin Kernel Version 15.6.0: Mon Jan 9 23:07:29 PST 2017; root:xnu-3248.60.11.2.1~1/RELEASE_X86_64
  6. $ go version
  7. go version go1.8 darwin/amd64
  8. $ vips -v
  9. vips-8.4.5-Sun Mar 19 07:06:21 WIB 2017
  10. ------------
  11. VM: Centos7-64bit
  12. Processor: SingleCore
  13. Memory: 768 MB
  14. $ uname -a
  15. Linux localhost.localdomain 3.10.0-327.36.1.el7.x86_64 #1 SMP Sun Sep 18 13:04:29 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
  16. $ go version
  17. go version go1.8 linux/amd64
  18. $ vips -v
  19. vips-8.4.5-Tue Mar 21 10:55:22 UTC 2017

INSTALL

  1. $ go get -u -v github.com/simukti/imageserver

USAGE

  1. $ imageserver
  2. [ERROR] Flag param -s is required
  3. Usage:
  4. -app string
  5. Allowed path prefix from source server, comma-separated for multiple values. (default "*")
  6. -h string
  7. Host port to serve this app. (default "127.0.0.1:8080")
  8. -m string
  9. Directory for master image storage. (default "/tmp/imgsrv_master")
  10. -r string
  11. Directory for result image storage. (default "/tmp/imgsrv_result")
  12. -s string
  13. Source server base URL. (Example: https://kadalkesit.storage.googleapis.com)
  14. -t int
  15. Process timeout per image processing request. (default 30)

Sample with allowed prefix path:

  1. $ imageserver -s https://storage.googleapis.com -h :8080 -app kadalkesit,kadalkesit-dev

Server will allow request:

BUT NOT:

SUPPORTED IMAGE PARAMETERS

  • w

    Output width (in pixel)

  • h

    Output height (in pixel)

  • q

    Output quality (JPG default 75)

  • fmt

    Output format (default: same as source)

  • blur

    Output image blur level (1-50)

  • c

    Output colour space (srgb, bw)

  • flip

    Output image flip (h : flip horizontally, v : flip vertically)

SAMPLE REQUEST

I use my photo from flickr.

  1. $ imageserver -s https://c1.staticflickr.com
  • Original Flickr: https://c1.staticflickr.com/9/8173/8045877062_481f4e80b4_b.jpg

    313.95 KB (321485 bytes)

  • Parsed as jpg (default): http://127.0.0.1:8080/9/8173/8045877062_481f4e80b4_b.jpg

    137.58 KB (140882 bytes)

  • Parsed as webp: http://127.0.0.1:8080/9/8173/8045877062_481f4e80b4_b.jpg?fmt=webp

    131.63 KB (134786 bytes)

  • Parsed as png: http://127.0.0.1:8080/9/8173/8045877062_481f4e80b4_b.jpg?fmt=png

    1,587.41 KB (1,625,510 bytes) !!!

NOTE

Source image file will be downloaded once and saved to master source folder.
Result file will be saved to result folder using filename based on hashed request params.
If requested params already exists that file will be returned without any further processing.

Is it fast ?? hmmm… I think it depends on hardware configuration ;) try it yourself.

LICENSE

This project is released under the MIT licence. See the LICENSE.md file for more.