@@ -25,7 +25,7 @@ The core image processing functionality is handled by the
25
25
26
26
- on the fly image thumbnail generation
27
27
- filesystem cache
28
- - URLs are [ Thumbor] ( https://github.com/thumbor/thumbor ) compliant
28
+ - URLs are [ Thumbor] ( https://github.com/thumbor/thumbor ) compatible
29
29
- service access can be restricted to avoid abuse
30
30
- Docker ready
31
31
- easy to set up
@@ -39,28 +39,39 @@ The core image processing functionality is handled by the
39
39
40
40
## Installation
41
41
42
- - clone this project
43
- - ``` npm install ```
42
+
43
+ ```
44
+ git clone git@github.com:chrisben/image-thumb.git && cd image-thumb
45
+ ```
46
+
47
+ ```
48
+ npm install
49
+ ```
44
50
45
51
## Usage
46
52
47
53
### Running the server
48
54
49
- ``` node index.js ```
55
+ ```
56
+ node index.js
57
+ ```
50
58
51
59
This will run a local server on: http://127.0.0.1:8081/
52
60
53
61
You can change the port number using the ` SERVER_PORT ` environment variable
54
62
(see _ Options_ below).
55
63
56
64
Alternatively you can run the server using gulp:
57
- ``` ./gulp serve ```
65
+
66
+ ```
67
+ ./gulp serve
68
+ ```
58
69
59
70
### Generating thumbnails
60
71
61
72
To create a thumbnail image:
62
73
63
- ``` http://127.0.0.1:8081/[HMAC/]WIDTHxHEIGHT/[HALIGN/VALIGN/]IMAGE_URL `` `
74
+ ` http://127.0.0.1:8081/[HMAC/]WIDTHxHEIGHT/[HALIGN/VALIGN/]IMAGE_URL `
64
75
65
76
- HMAC: security token
66
77
- WIDTH: new width in pixels
@@ -85,7 +96,7 @@ to keep the original aspect ratio. For instance:
85
96
86
97
Options and their defaults are set in the services/options.js file.
87
98
These options can be overridden via environment variables.
88
- For instance you can run: ``` LOG_LEVEL=0 node index.js `` ` to start the server
99
+ For instance you can run: ` LOG_LEVEL=0 node index.js ` to start the server
89
100
with logging disabled.
90
101
91
102
### Security
@@ -111,23 +122,21 @@ The command line tool `command/hmac.js` is provided to generate tokens.
111
122
112
123
Let's say I want to use the 'mytest' security key like this:
113
124
114
- ` SECURITY_KEY=mytest node index.js `
125
+ ```
126
+ SECURITY_KEY=mytest node index.js
127
+ ```
115
128
116
- From the given thumbnail URL:
129
+ From the given thumbnail URL: ` http://127.0.0.1:8081/300x100/https://www.google.fr/images/logo.png `
117
130
118
- ` http://127.0.0.1:8081/300x100/https://www.google.fr/images/logo.png `
119
-
120
- We extract the path:
121
-
122
- ` /300x100/https://www.google.fr/images/logo.png `
131
+ We extract the path: ` /300x100/https://www.google.fr/images/logo.png `
123
132
124
133
Let's generate the security token (HMAC):
125
134
126
- ` node command/hmac.js mytest /300x100/https://www.google.fr/images/logo.png `
127
-
128
- We get the following security token:
135
+ `` `
136
+ node command/hmac.js mytest /300x100/https://www.google.fr/images/logo.png
137
+ ```
129
138
130
- ` 4a79a53213c97c615e4ef50e856dd7797c9dbdb9 `
139
+ We get the following security token: ` 4a79a53213c97c615e4ef50e856dd7797c9dbdb9 `
131
140
132
141
Now the thumbnail image can be accessed using the following URL:
133
142
@@ -159,11 +168,15 @@ is not downloaded again and instead loaded directly from the filesystem cache.
159
168
160
169
To build a docker container running the server:
161
170
162
- ` docker build . `
171
+ ```
172
+ docker build .
173
+ ```
163
174
164
175
To run it:
165
176
166
- ` docker run -p 8081:8081 DOCKER_IMAGE_ID `
177
+ ```
178
+ docker run -p 8081:8081 DOCKER_IMAGE_ID
179
+ ```
167
180
168
181
## TODO
169
182
0 commit comments