Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A node.js module to resize, crop and upload images to Rackspace cloudfiles and Amazon S3
JavaScript

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
History.md
Makefile
README.md
imager-example.js
index.js
package.json

README.md

Imager

A Node.js module to easily resize, crop and upload images to Rackspace cloudfiles. Possible to add different versions of the same file in cropped or resized variant.

Installation

$ npm install imager

Usage

You need to create imager configuration file with image variants and your storages

Checkout the example config file imager-example.json in the repo

var Imager = require('imager');
var imager = new Imager({storage : "rs", config_file: "path/to/imager_config.json"})

Uploading file(s)

The callback recieves an err object, a files array (containing the names of the files which were uploaded) and the cdnUri.

So if you have a variant, say thumb, then you can access the image by cdnUri+'/'+'thumb_'+files[0]. This would be the complete url of the image

  1. Form upload

    imager.upload(req, function(err, files, cdnUri){
        // do your stuff
    }, 'projects')
  2. Upload files from disk

    You can upload a single file or multiple files by providing the paths to all the files in an array

    Upload Single file from disk:

    imager.upload('path/to/file.jpg', function(err, files, cdnUri){
        // do your stuff
    }, 'projects')

    Upload multiple files from disk:

    var files = ['file1.jpg', 'file2.jpg']
    imager.upload(files, function(err, files, cdnUri){
        // do your stuff
    }, 'projects')
  3. Upload files from remote url

    imager.uploadRemoteImage('https://www.google.co.in/images/srpr/logo3w.png', function(err, files, cdnUri){
        // do your stuff
    }, 'projects')

Removing file(s)

  1. Remove a single file

    imager.remove('1330838831049.png', function (err) {
        // do your stuff
    }, 'projects')
  2. Remove multiple files

    var files = ['1330838831049.png', '1330838831049.png']
    imager.remove(files, function (err) {
        // do your stuff
    }, 'projects')

To-do's

  • Support amazon storage
  • Support filesystem storage
  • Remove using of eval
  • Add functionality to remove files
  • Write tests
Something went wrong with that request. Please try again.