-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
154 lines (116 loc) · 4.36 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
Name
ngx_imaging_module - Dynamic image manipulation for arbitrary Nginx locations.
Status
This module is in development. [beta]
Version
0.0.1 - Initial internal release.
Synopsis
http {
server {
location {
error_page 404 = @img;
recursive_error_pages on;
}
location @img {
# try to create the image
imaging "on";
imaging_quality 70;
imaging_salt "Shared secrete hash salt";
imaging_white_list "t400 t480";
imaging_write_to_disk "on";
}
}
}
Directives
imaging
syntax: imaging on|off
default imaging off
context: http, server, location
imaging_salt
syntax: imaging_salt "my salt string";
default ""
context: http, server, location
imaging_quality
syntax: imaging_quality 70;
default 70
context: http, server, location
imaging_white_list
syntax: imaging_white_list "t200 t400 t400x400 r400";
default ""
context: http, server, location
imaging_write_to_disk
syntax: imaging_write_to_disk on|off;
default on
context: http, server, location
Description
ngx_imaging_module is an Nginx extension which allows you to create images
based on modifications to existing images. By delaying the generation of
transformed images until the time of request, your able to 'pay only for
what you eat'.
Image transformations are encoded into the file name in a 'somewhat' human
readable form, where each transformation is separated by an underscore in the
filename.
The module uses the GraphicsMagick 'core C API' to perform the various image
transformations. GraphicsMagick is a fork of ImageMagick which leverages
OpenMP technologies to squeeze out more performance.
Security
Shared salt key:
- A salt is used in the creation of a hash string which is
passed from the calling application to the server to verify its
authenticity.
Image Transformations
ngx_imaging_module currently supports the following transformations.
Border
Apply a border around an Image.
Examples:
b5-black - 5px Black border
b1-red - 1px Red border
Crop
Create a new image by cropping of the center of an existing image.
Examples:
c200
c200x200
cx200
Scale
Resize an image ignoring the aspect ratio.
Examples:
s200
s200x200
sx200
Resize
Resize an image preserving the aspect ratio.
Examples:
r200
r200x200
rx200
Thumbnail
Resize an image preserving the aspect ratio.
Examples:
t200
t200x200
tx200
Note: These transformations can be chained together sperated by underscores.
Example:
t200_b1-black - Thumbnail to 200 wide and add a 1px black border.
r400x400_c200x200 - Resize to 400x400 then crop 200x200 out of that.
Installation
Dependencies:
GraphicMagick - Image manipulation library.
Can be installed via normal Ubuntu apt-get:
dev@box:~$ sudo apt-get install libmagickcore-dev
# you may have to pull (libgraphicsmagick1-dev libgraphicsmagick3)
Check that GraphicsMagic-config (build utilty program) is installed.
dev@box:~$ GraphicsMagick-config --cppflags --ldflags --libs
that should return something like:
-I/usr/include/GraphicsMagick
-L${exec_prefix}/lib
-lGraphicsMagick -llcms -ltiff -lfreetype -ljasper -ljpeg -lpng -lwmflite -lXext -lSM -lICE -lX11 -lbz2 -lxml2 -lz -lm -lgomp -lpthread -lltdl
OpenSSH - Contains SHA1 hash algorithm.
Install:
Download the modules source (either via bzr, or a source tarball).
Then compile nginx as you would normally adding the following:
--add-module=/path/to/ngx_imaging_module/
Nginx will hook the config file located in that directory and use
it to pull in all the source files (as well as config the build).
Testing:
Under /test