Giter Club home page Giter Club logo

imgwizard's Introduction

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.

imgwizard's People

Contributors

shifr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imgwizard's Issues

Limit resize size by size of original

It's possible to send request with size bigger than original. Much more bigger:
ll 133/fc3cb123-cf43-45d3-822f-472aa84f5389_546e81b73d4fbe9472b041afd9723227_1x1_41400x57600.jpeg -h
-rw-r--r-- 1 www www 46M Oct 17 13:27 fc3cb123-cf43-45d3-822f-472aa84f5389_546e81b73d4fbe9472b041afd9723227_1x1_41400x57600.jpeg

You can easily use this to overflow cache partition.
Wise solution will be - return original size if requested sizemore than original

Add ability to notify each process about others

Something like this:
imgw1, imgw2, imgw3, imgw4
imgw1 knows about imgw2, imgw3, imgw4
imgw2 knows about imgw1, imgw3, imgw4 etc.

Therefore we can cache one file one time at one node and request each node before process resize. It prevents overcaching

Add media white list

Add config for remote media white list to prevent use your imgwizard by others

Single axis scaling works inconsistently across axes

e.g.

Cropping by sides

Add GET parameters "?crop=side1,side2". Now images are cropped by center

Stats page

add statistic page to get performance stats:
current active/waiting request,
received/accepted/processed requests from daemon start

Deploying to aws lambda

Would it be possible? Serverless solution is far more reliable and cheap than servers in this case

HEAD request returns 404

> curl -I https://media.modnakasta.ua/imgw/loc/460x280/uploads/campaign/2015/07/050/d3d93a5a-ae5b-4240-b2af-c7db0c16635a_ac5201fe3f0e21da034828d97a07de3c.jpg                                                            
HTTP/1.1 404 Not Found
Server: nginx
Date: Mon, 06 Jul 2015 09:07:58 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 19
Connection: keep-alive

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.