Giter VIP home page Giter VIP logo

image-server's Introduction

blomming-image-server

This is a first experimental release of the ultra-fast image server that automatically resizes images taken from S3.

Run locally

Dependencies

(Tested on Ubuntu 13.04). The image server relies on graphicsmagick. You should install the latest version available. You can find it on sourceforge at: http://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/

Then you need to install also the jpeg and png extensions, otherwise it won't convert the images. You can find them here: http://www.imagemagick.org/download/delegates/

Every packet should be installed with the usual procedure:

.\configure
make
make test
sudo make -n install
sudo make install

After that, try to type "gm version" at the console. If you get:

gm: error while loading shared libraries: libjpeg.so.9: cannot open shared object file: No such file or directory

Try with:

sudo ranlib /usr/local/lib/libjpeg.a
sudo ldconfig /usr/local/lib

Configuration

This image server is configured by environment variables, you should set them like these:

export AWS_KEY=YOUR_AWS_KEY_HERE
export AWS_SECRET=YOUR_AWS_SECRET_HERE
export S3_BUCKET=YOUR_BUCKET_HERE

Startup

Execute the following commands in your terminal:

git clone https://github.com/njvitto/blomming-image-server
cd blomming-image-server
npm install
./image-server.js

Run on Heroku

Create the app

Execute the following commands in your terminal:

git clone https://github.com/njvitto/blomming-image-server
cd blomming-image-server
gem install heroku
heroku create <YOUR_APP_NAME>
git push heroku

Configuration

This image server is configured by environment variables, you should set them like these:

heroku config:set AWS_KEY=YOUR_AWS_KEY_HERE
heroku config:set AWS_SECRET=YOUR_AWS_SECRET_HERE
heroku config:set S3_BUCKET=YOUR_BUCKET_HERE

Usage

Once started, resizing image is really easy, it's just needed to call a specific URL.

Contain

Creates an image whose sizes are at max the ones specified.

curl http://<YOUR_URL>/w<WIDTH>/h<HEIGHT>/for/<PATH_ON_S3_OF_THE_IMAGE>
curl http://<YOUR_URL>/w<WIDTH>/for/<PATH_ON_S3_OF_THE_IMAGE>

Cover

Creates an image whose sizes are exactly the ones specified. The reduced image is obtained "cutting out" the exceding part of the image to fit the new aspect ratio.

curl http://<YOUR_URL>/cover/w<WIDTH>/h<HEIGHT>/for/<PATH_ON_S3_OF_THE_IMAGE>

Crop

Creates an image whose sizes are exactly the ones specified. The reduced image is obtained picking it from a rectangle of the same sizes from the center of the image.

curl http://<YOUR_URL>/crop/w<WIDTH>/h<HEIGHT>/for/<PATH_ON_S3_OF_THE_IMAGE>

Internals

This server operates in the following manner:

  1. tries to get the resized image, if so it returns it to the user;
  2. if there is no resized image, it resizes it using the convert utility from imagemagick;
  3. it forwards the resized image to the user;
  4. it loads the resized image to S3 for later usage.

image-server's People

Contributors

paolochiodi avatar

Watchers

James Cloos avatar Richard Clayton avatar

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.