搭建过程

1
docker run --name tinypng -d  -p 9000:9000 h2non/imaginary -enable-url-source -cors

使用方法

原始图片

1
http://media.freshfresh.com/media/catalog/product/1/_/1_44_61.jpg

小图

1
http://server.host.com:9000/crop?width=100000000&url=http://media.freshfresh.com/media/catalog/product/1/_/1_44_61.jpg

关于imaginary

Supported image operations

  • Resize
  • Enlarge
  • Crop
  • Rotate (with auto-rotate based on EXIF orientation)
  • Flip (with auto-flip based on EXIF metadata)
  • Flop
  • Zoom
  • Thumbnail
  • Configurable image area extraction
  • Embed/Extend image, supporting multiple modes (white, black, mirror, copy or custom background color)
  • Watermark (customizable by text)
  • Custom output color space (RGB, black/white…)
  • Format conversion (with additional quality/compression settings)
  • Info (image size, format, orientation, alpha…)
  • Reply with default or custom placeholder image in case of error.

项目地址 https://github.com/h2non/imaginaryhttps://github.com/h2non/bimg ,https://github.com/jcupitt/libvips

imageinary是对bimg做的web接品封装

bimg是对libvips做的golang封装

libvips是一个c/c++写的图像处理库