Skip to content

Commit 7a44b07

Browse files
author
Alexandru Badiu
committed
fix(readme): Updated README, make default parameters consistent.
Updated the documentation. Made the gravity default parameters consistent.
1 parent 18946e3 commit 7a44b07

File tree

2 files changed

+111
-13
lines changed

2 files changed

+111
-13
lines changed

README.md

Lines changed: 110 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,113 @@ The render callback returns a `sharp` instance which can be used in various ways
8383

8484
## Imagecache actions:
8585

86-
* Blur []
87-
* Define canvas []
88-
* File []
89-
* Flip []
90-
* Gamma []
91-
* Greyscale []
92-
* Negate []
93-
* Normalize []
94-
* Rotate []
95-
* Scale []
96-
* Scale and crop []
97-
* Sharpen []
86+
### Blur
87+
88+
Blurs the image.
89+
90+
Action name: `blur`.
91+
92+
Configuration:
93+
* blur: A value between 0.3 and 1000 representing the sigma of the Gaussian mask. Defaults to `1`.
94+
95+
### Define canvas
96+
97+
Defines a new canvas and overlays the current image.
98+
99+
Action name: `define_canvas`.
100+
101+
Configuration:
102+
* width: The width of the canvas.
103+
* height: The height of the canvas.
104+
* channels: Number of channels. Defaults to `4`.
105+
* background: The background color of the canvas in hex format.
106+
107+
### File
108+
109+
Loads an image and overlays it on the current image.
110+
111+
Action name: `file`.
112+
113+
Configuration:
114+
* path: The path of the file.
115+
* gravity: Gravity at which to place the overlay. Possible values are `north`, `northeast`, `east`, `southeast`, `south`, `southwest`, `west`, `northwest`, `center` and `centre`. Defaults to `center`.
116+
* tile: Set to true to repeat the overlay image across the entire image with the given `gravity`. Defaults to `false`.
117+
* cutout: Set to true to apply only the alpha channel of the overlay image to the input image, giving the appearance of one image being cut out of another. Defaults to `false`.
118+
119+
### Flip
120+
121+
Flips the image on a given axis.
122+
123+
Action name: `flip`.
124+
125+
Configuration:
126+
* axis: The axis to flip on. Defaults to `y`.
127+
128+
### Gamma
129+
130+
Apply a gamma correction to the image.
131+
132+
Action name: `gamma`.
133+
134+
Configuration:
135+
* gamma: Value between 1.0 and 3.0. Defaults to `2.2`.
136+
137+
### Greyscale
138+
139+
Convert to 8-bit greyscale, 256 shades of grey.
140+
141+
Action name: `greyscale`.
142+
143+
### Negate
144+
145+
Produce the "negative" of the image.
146+
147+
Action name: `negate`.
148+
149+
### Normalize
150+
151+
Enhance output image contrast by stretching its luminance to cover the full dynamic range.
152+
153+
Action name: `normalize`.
154+
155+
### Rotate
156+
157+
Rotates the image based on the EXIF data or at a specified angle.
158+
159+
Action name: `rotate`.
160+
161+
Configuration:
162+
* angle: Angle, multiple of 90. Defaults to `auto` which uses EXIF.
163+
164+
### Scale
165+
166+
Scales the image ignoring the aspect ratio.
167+
168+
Action name: `scale`.
169+
170+
Configuration:
171+
* width: The width of the new image. Can be a number or a percent value.
172+
* height: The height of the new image. Can be a number or a percent value.
173+
174+
### Scale and crop
175+
176+
Scales and crops the image mantaining the aspect ratio.
177+
178+
Action name: `scale_and_crop`.
179+
180+
Configuration:
181+
* width: The width of the new image. Can be a number or a percent value.
182+
* height: The height of the new image. Can be a number or a percent value.
183+
* gravity: Where to crop from. Possible values are `north`, `northeast`, `east`, `southeast`, `south`, `southwest`, `west`, `northwest`, `center` and `centre`. Defaults to `center`.
184+
185+
### Sharpen
186+
187+
Sharpen the image.
188+
189+
Action name: `sharpen`.
190+
191+
Configuration:
192+
* sigma: The sigma of the Gaussian mask. Defaults to `1`.
193+
* flat: The level of sharpening to apply to "flat" areas. Defaults to `1.0`.
194+
* jagged: The level of sharpening to apply to "jagged" areas. Defaults to `2.0`.
195+

src/plugins/file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = {
44
const filepath = config.path;
55

66
const options = {
7-
gravity: config.gravity,
7+
gravity: config.gravity || 'center',
88
tile: config.tile || false,
99
cutout: config.cutout || false,
1010
};

0 commit comments

Comments
 (0)