Giter VIP home page Giter VIP logo

resizing_image_server.js's Introduction

In a web application, uploaded images are often needed in different sizes. This server resizes an image when first serving it, and caches it for faster serving on the next requests. This makes it very easy to add new image sizes later on, since nothing has to be pre-generated. The server uses node.js and ImageMagick.

Example

Request http://127.0.0.1:8000/200/sammy-davis-jr.jpg, and it sends this image in width 200, regardless if this size existed earlier. The only requirement is that the original size image exists.

It the resized image already exists, it will be served directly. If not, it is created, cached and served.

Installation

Install node.js first: http://nodejs.org/#download

> git clone [email protected]:phillipoertel/resizing_image_server.js.git resizing_image_server
> cd resizing_image_server
> rake setup
This will set up the following structure:

`— images
|— originals
`— resized
|— 100
|— 200

> node resizing_image_server.js

Now point your browser to: http://127.0.0.1:8000/200/sammy-davis-jr.jpg

Adding more sizes

To add a new size, create a new directory below “resized”.
This is the only way you control which image sizes are available.

Sizes currently can only be URL- and filesystem neutral strings, but with a bit of escaping all Image Magick geometry strings (http://is.gd/cjcci) should be supportable. The geometry is passed on to Image Magick directly from the URL.

Throughput

Stats for node version 0.1.96 on my local machine (OS X Intel Core 2 Duo 2.66GHz, 4GB RAM, SSD HD)

Disclaimer

This is a proof of concept, consider it alpha software.

resizing_image_server.js's People

Contributors

phillipoertel avatar

Stargazers

Gun.io Robot avatar Bernhard Gschwantner avatar  avatar Sven Hohlfeld avatar Andrew Seddon avatar  avatar Victor Stan avatar Bjarki Heiðar Ingason avatar Justin Leider avatar Michael LeBarron avatar Pascal Friederich avatar Steffen Leistner avatar Chris Frohoff avatar  avatar

Watchers

James Cloos avatar

Forkers

guniorobot

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.