Skip to content
This repository
Browse code

update readme

  • Loading branch information...
commit 170122a143f90f18b5a2fb2100bc28dd6124a8f8 1 parent 82db016
Madhusudhan Srinivasa authored

Showing 1 changed file with 23 additions and 44 deletions. Show diff stats Hide diff stats

  1. +23 44 README.md
67 README.md
Source Rendered
... ... @@ -1,22 +1,28 @@
1 1 Imager
2 2 =============
3 3
4   -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.
  4 +A Node.js module to easily resize, crop and upload images (with different variants and presets) to Rackspace cloudfiles.
5 5
6 6 ## Installation
7 7 ```sh
8 8 $ npm install imager
9 9 ```
10 10
  11 +**Note** : _Uptil v0.0.8 the module supported filesystem uploads and external (remote) image uploads, but the module was completely re-written
  12 +to use async and make it much faster. The 0.0.9 version of the module doesn't support file system uploads.
  13 +I will try to add it back soon. You can revert back to older versions if you need filesystem support etc_
  14 +
11 15 ## Usage
12 16 **You need to create imager configuration file with image variants and your storages**
13 17
14   -Checkout the example config file `imager-example.json` in the repo
  18 +Checkout the example config file `imager-example.js` in the repo
15 19
16 20 ```js
17 21 var Imager = require('imager');
18   -var imager = new Imager({storage : "rs", config_file: "path/to/imager_config.json"})
  22 + , imagerConfig = require('path/to/imager-config.js')
  23 + , imager = new Imager(imagerConfig, 'Rackspace')
19 24 ```
  25 +
20 26 ### Uploading file(s)
21 27
22 28 The callback recieves an err object, a files array (containing the names of the files which were
@@ -24,55 +30,22 @@ uploaded) and the cdnUri.
24 30
25 31 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
26 32
27   -1. **Form upload**
  33 +1. **Form upload (multiple images)**
28 34
29 35 ```js
30   - imager.upload(req, function(err, files, cdnUri){
  36 + imager.upload(req.files.image, function(err, cdnUri, files) {
31 37 // do your stuff
32 38 }, 'projects')
33 39 ```
34 40
35   -2. **Upload files from disk**
36   -
37   - You can upload a single file or multiple files by providing the paths to all the files
38   - in an array
39   -
40   - _Upload Single file from disk_:
41   -
42   - ```js
43   - imager.upload('path/to/file.jpg', function(err, files, cdnUri){
44   - // do your stuff
45   - }, 'projects')
46   - ```
47   -
48   - _Upload multiple files from disk_:
49   -
50   - ```js
51   - var files = ['file1.jpg', 'file2.jpg']
52   - imager.upload(files, function(err, files, cdnUri){
53   - // do your stuff
54   - }, 'projects')
55   - ```
  41 + Here, `projects` is your scope or variant. If you don't specify the scope or the variant, imager
  42 + will try to look for a default variant named `default`. You must either specify a variant like
  43 + above or provide a `default` variant.
56 44
57   -3. **Upload files from remote url**
58   -
59   - ```js
60   - imager.uploadRemoteImage('https://www.google.co.in/images/srpr/logo3w.png', function(err, files, cdnUri){
61   - // do your stuff
62   - }, 'projects')
63   - ```
64 45
65 46 ### Removing file(s)
66 47
67   -1. **Remove a single file**
68   -
69   - ```js
70   - imager.remove('1330838831049.png', function (err) {
71   - // do your stuff
72   - }, 'projects')
73   - ```
74   -
75   -2. **Remove multiple files**
  48 +1. **Remove from cloudfiles**
76 49
77 50 ```js
78 51 var files = ['1330838831049.png', '1330838831049.png']
@@ -81,10 +54,16 @@ So if you have a variant, say `thumb`, then you can access the image by `cdnUri+
81 54 }, 'projects')
82 55 ```
83 56
  57 + Even here, if the variant is not specified, imager will try to look for the `default` variant. If neither
  58 + of them are provided, you will get an error.
  59 +
  60 +## Debugging
  61 +If you specify `debug: true` in the imager config, you can see the logs of uploaded / removed files.
  62 +
84 63 ## To-do's
85 64 * Support amazon storage
86 65 * Support filesystem storage
87   -* <strike>Remove using of `eval`</strike>
88   -* <strike>Add functionality to remove files</strike>
89 66 * Write tests
90 67
  68 +
  69 +**credits :** Initially inspired by [Alleup](https://github.com/tih-ra/alleup)

0 comments on commit 170122a

Please sign in to comment.
Something went wrong with that request. Please try again.