Node Gallery

NodeJS Photo Gallery built on Express 4.
Feed it a directory of photos, get back a JSON object & a styled photo gallery ready for the web.

No database needed

Strictly no frills

Folders titles => Album titles

Image titles => Photo Titles

EXIF title => Description

Displays camera capture info (exposure, aperture, ISO..)

Installation

$ npm install --save node-gallery

Usage

Node gallery can be used standalone, or in an existing node.js application. The example code has support for the Openshift and Heroku PaaS.

In Existing Applications

Node Gallery exposes express style middleware, meaning it can be mounted to any route within your application.

/*
@param {string, required} staticFiles The directory where your album starts - can contain photos or images
@param {string, required} urlRoot The root URL which you pass into the epxress router in app.use (no way of obtaining this otherwise)
@param {string, optional} title Yup, you guessed it - the title to display on the root gallery
@param {boolean, optional} render Default to true. If explicitly set to false, rendering is left to the next function in the chain - see below.
@param {string, optional} thumbnail.width Thumbnail image width, defaults '200'
@param {string, optional} thumbnail.height as above
@param {string, optional} image.width Large images width defaults '100%'
@param {string, optional} image.height as above
*/
app.use('/gallery', require('node-gallery')({
staticFiles : 'resources/photos',
urlRoot : 'gallery',
title : 'Example Gallery'
}));

Now, you can access the gallery by going to your application's url /gallery - in the case of our example, http://localhost:3000/gallery.

Providing Views

The middleware renders the views in the views directory by default, but you can override this behavior & provide your own view rendering by setting render to false.
When this happens, the gallery HTML is returned in req.html, the raw JSON data in req.data.

Running Standalone

Node Gallery can be run standalone for testing.
Modify examples/app.js to your liking, then add your albums & images to examples/resources/photos & run using:

cd example
npm install -d
node app.js

Examples

Node Gallery with out-of-the-box configuration is deployed to Heroku - see it here.

A basic usage example showing how to use node-gallery with Express can be found in examples/basic.js.

A more advanced example, showing how to take control of the rendering of your pages is shown in examples/app.js.

To try these examples:

cd examples
npm install -d
node app.js # or node basic.js

Photos

Photos are added to your specified staticFiles directory. Albums are created for every folder we encounter, and thumbnails are automatically generated by using the first image we come across in this album.