/imgwizard

Simple server for On-the-Fly image processing in Go

Primary LanguageGoMIT LicenseMIT

ImgWizard - fast, light, easy to use

Build Status

Under active development. Please, use latest stable release.

What is it?

ImgWizard is a small server written in Go as faster alternative for thumbor

What it can do?

  • Fetch original image from:
    • local file system
    • remote media storage (using http)
    • microsoft azure (using SDK)
    • amazon s3 (using SDK)
  • Resize it
  • Crop it
  • Change quality
  • Cache resized image and fetch it on next request:
    • to file system
    • to Amazon S3
    • to Microsoft Azure Storage
  • Return WebP images if browser supports it

How to use?

http://{server}/{mark}/{storage}/{size}/{path_to_file}?{params}

  • server - imgwizard server addr
  • mark - mark for url (can be used for nginx proxying)
  • storage - "loc" (local file system) or "rem" (remote media) or "az" (azure storage)
  • size - "320x240" or "320x" or "x240"
  • path_to_file - path to original file (without "http://")
  • params - query parameters
Params:
  • crop - sides fixed when cropping (top, right, bottom, left)
  • q - result image quality (default set from command line "-q")
  • original ("true" or "false", default - "false") - return original image without processing and saving to cache
Example:

http://192.168.0.1:4444/images/rem/462x/media.google.com/uploads/images/1/test.jpg?crop=top,left&q=90

How to install?

Installing libvips

VIPS is a free image processing system. Compared to similar libraries, VIPS is fast and does not need much memory, see the Speed and Memory Use page. As well as JPEG, TIFF, PNG and WebP images, it also supports scientific formats like FITS, OpenEXR, Matlab, Analyze, PFM, Radiance, OpenSlide and DICOM (via libMagick). (© vips wiki)

Mac OS

$ brew tap homebrew/science

$ brew install vips --with-webp

Debian based

$ sudo apt-get install libvips-dev

RedHat

$ yum install libwebp-devel glib2-devel libpng-devel libxml2-devel libjpeg-devel

$ wget http://www.vips.ecs.soton.ac.uk/supported/7.38/vips-7.38.5.tar.gz

$ tar xvzf vips-7.38.5.tar.gz; cd vips-7.38.5

$ ./configure

$ make

$ make install

$ echo '/usr/local/lib' > /etc/ld.so.conf.d/libvips.conf

$ ldconfig -v

Installing imgwizard

  • go get github.com/shifr/imgwizard/cmd/imgwizard
  • export PATH=$PATH:$GOPATH/bin if you haven't done it before

Running imgwizard

  • imgwizard - run server without restrictions

You will see "ImgWizard started..."

Check imgwizard work after server start

Doesn't work?

Try to add PKG_CONFIG_PATH into environment:

export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/lib/pkgconfig"

Parameters on start?

DEBUG_ENABLED=1 WARNING_ENABLED=1 imgwizard -l localhost:9000 -c /tmp/my_cache_dir -thumb /tmp/404.jpg -d /v1/uploads,/v2/uploads -m media1.com,media2.com -s 100x100,480x,x200 -q 80 -mark imgw -nodes 127.0.0.1:8071,127.0.0.1:8072 -no-cache-key 123

ENV

  • DEBUG_ENABLED: show all debug messages
  • WARNING_ENABLED: show warning messages (when image not found/processed)

Flags

  • -l: Address to listen on (default - "localhost:8070")
  • -s3-b: Amazon S3 bucket name where cache will be located (for current wizard node).
  • -az: Microsoft Azure Storage container name where cache will be located (for current wizard node).
  • -c: directory for cached files (WORKS if "-s3-b" not specified, default - "/tmp/imgwizard")
  • -thumb: absolute path to default image if original not found (optional)
  • -m: comma separated list of allowed media (default - all enabled)
  • -s: comma separated list of allowed sizes (default - all enabled)
  • -d: comma separated list of directories to search original file
  • -q: resized image quality (default - 80)
  • -mark: mark (default - images)
  • -nodes: comma separated list of other imgwizard nodes for cache check (see nodes)
  • -no-cache-key: secret key that must be equal X-No-Cache value from request header to prevent reading from cache

Use Amazon S3 for caching OR as a storage for original image?

Then you should specify more ENV variables:

  • AWS_REGION: where to send requests. (Example: "us-west-2") //Required
  • AWS_ACCESS_KEY_ID: your access key id
  • AWS_SECRET_ACCESS_KEY: your secret access key

Use Azure Storage for caching OR as a storage for original image?

Then you should specify more ENV variables:

  • AZURE_ACCOUNT_NAME: your azure account name
  • AZURE_ACCOUNT_KEY: your key for SDK auth

Who are already using it?

Plans?

Yes, a lot.