You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
[](https://app.codeship.com/projects/225818)[](https://www.npmjs.com/package/imagecache-sharp)
1
+
[](https://www.npmjs.com/package/imagecache-sharp)
The render callback returns a `sharp` instance which can be used in various ways for outputting the final image. For a list of options see [sharp's documentation](http://sharp.dimens.io/en/stable/api-output/).
41
+
The render function returns a `sharp.Sharp` instance (`Image` is just an alias for it) which can be used in various ways for outputting the final image. For a list of options see [sharp's documentation](https://sharp.pixelplumbing.com/api-constructor).
46
42
47
43
## Presets structure
48
44
45
+
A preset is defined like this:
46
+
47
+
```typescript
48
+
typePreset= {
49
+
presetName:string;
50
+
actions:Action[];
51
+
};
49
52
```
50
-
{
51
-
preset_one: {
52
-
presetname: 'preset_one',
53
+
54
+
An action contains an operation (which is defined by the plugins) and an optional config.
55
+
56
+
```typescript
57
+
typeAction= {
58
+
action:string;
59
+
config?:any;
60
+
};
61
+
```
62
+
63
+
Here are two example presets. The first one resizes and crops the image, puts it on a bigger canvas, then blurs it. The second one resizes and crops the image.
64
+
65
+
```typescript
66
+
exportdefault [
67
+
{
68
+
presetName: 'canvas_scale_with_blur',
53
69
actions: [
54
70
{
55
71
action: 'scale_and_crop',
56
72
config: {
57
-
width: 100,
58
-
height: 300
59
-
}
73
+
width: 152,
74
+
height: 152,
75
+
},
60
76
},
61
77
{
62
78
action: 'define_canvas',
63
79
config: {
64
80
color: '#333333',
65
-
width: 400,
66
-
height: 400,
67
-
xpos: 'center',
68
-
ypos: 'center'
69
-
}
70
-
}
71
-
]
81
+
width: 400,
82
+
height: 400,
83
+
},
84
+
},
85
+
{
86
+
action: 'blur',
87
+
},
88
+
],
72
89
},
73
-
preset_two: {
74
-
presetname: 'preset_two',
90
+
{
91
+
presetName: 'scale_crop_tiny',
75
92
actions: [
76
93
{
77
94
action: 'scale_and_crop',
78
95
config: {
79
-
width: 70,
80
-
height: 70,
81
-
}
82
-
}
83
-
]
84
-
}
85
-
}
96
+
width: 32,
97
+
height: 32,
98
+
},
99
+
},
100
+
],
101
+
},
102
+
];
86
103
```
87
104
88
105
## Imagecache actions:
@@ -94,7 +111,8 @@ Blurs the image.
94
111
Action name: `blur`.
95
112
96
113
Configuration:
97
-
* blur: A value between 0.3 and 1000 representing the sigma of the Gaussian mask. Defaults to `1`.
114
+
115
+
-`sigma`: A value between 0.3 and 1000 representing the sigma of the Gaussian mask. Defaults to `50`.
98
116
99
117
### Define canvas
100
118
@@ -103,10 +121,11 @@ Defines a new canvas and overlays the current image.
103
121
Action name: `define_canvas`.
104
122
105
123
Configuration:
106
-
* width: The width of the canvas.
107
-
* height: The height of the canvas.
108
-
* channels: Number of channels. Defaults to `4`.
109
-
* background: The background color of the canvas in hex format.
124
+
125
+
-`width`: The width of the canvas.
126
+
-`height`: The height of the canvas.
127
+
-`channels`: Number of channels. Defaults to `4`.
128
+
-`background`: The background colour of the canvas in hex format.
110
129
111
130
### File
112
131
@@ -115,10 +134,10 @@ Loads an image and overlays it on the current image.
115
134
Action name: `file`.
116
135
117
136
Configuration:
118
-
* path: The path of the file.
119
-
* 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`.
120
-
* tile: Set to true to repeat the overlay image across the entire image with the given `gravity`. Defaults to `false`.
121
-
* 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`.
137
+
138
+
-`path`: The path of the file.
139
+
-`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`.
140
+
-`tile`: Set to true to repeat the overlay image across the entire image with the given `gravity`. Defaults to `false`.
122
141
123
142
### Flip
124
143
@@ -127,7 +146,8 @@ Flips the image on a given axis.
127
146
Action name: `flip`.
128
147
129
148
Configuration:
130
-
* axis: The axis to flip on. Defaults to `y`.
149
+
150
+
-`axis`: The axis to flip on. Defaults to `y`.
131
151
132
152
### Gamma
133
153
@@ -136,7 +156,8 @@ Apply a gamma correction to the image.
136
156
Action name: `gamma`.
137
157
138
158
Configuration:
139
-
* gamma: Value between 1.0 and 3.0. Defaults to `2.2`.
159
+
160
+
-`gamma`: Value between 1.0 and 3.0. Defaults to `2.2`.
140
161
141
162
### Greyscale
142
163
@@ -163,7 +184,8 @@ Rotates the image based on the EXIF data or at a specified angle.
163
184
Action name: `rotate`.
164
185
165
186
Configuration:
166
-
* angle: Angle, multiple of 90. Defaults to `auto` which uses EXIF.
187
+
188
+
-`angle`: Angle, multiple of 90. Defaults to `auto` which uses EXIF.
167
189
168
190
### Scale
169
191
@@ -172,19 +194,22 @@ Scales the image ignoring the aspect ratio.
172
194
Action name: `scale`.
173
195
174
196
Configuration:
175
-
* width: The width of the new image. Can be a number or a percent value.
176
-
* height: The height of the new image. Can be a number or a percent value.
197
+
198
+
-`width`: The width of the new image. Can be a number or a percent value.
199
+
-`height`: The height of the new image. Can be a number or a percent value.
200
+
-`upscale`: Whether to upscale the image. Defaults to true.
177
201
178
202
### Scale and crop
179
203
180
-
Scales and crops the image mantaining the aspect ratio.
204
+
Scales and crops the image maintaining the aspect ratio.
181
205
182
206
Action name: `scale_and_crop`.
183
207
184
208
Configuration:
185
-
* width: The width of the new image. Can be a number or a percent value.
186
-
* height: The height of the new image. Can be a number or a percent value.
187
-
* gravity: Where to crop from. Possible values are `north`, `northeast`, `east`, `southeast`, `south`, `southwest`, `west`, `northwest`, `center` and `centre`. Defaults to `center`.
209
+
210
+
-`width`: The width of the new image. Can be a number or a percent value.
211
+
-`height`: The height of the new image. Can be a number or a percent value.
212
+
-`gravity`: Where to crop from. Possible values are `north`, `northeast`, `east`, `southeast`, `south`, `southwest`, `west`, `northwest`, `center` and `centre`. Defaults to `center`.
188
213
189
214
### Sharpen
190
215
@@ -193,7 +218,7 @@ Sharpen the image.
193
218
Action name: `sharpen`.
194
219
195
220
Configuration:
196
-
* sigma: The sigma of the Gaussian mask. Defaults to `1`.
197
-
* flat: The level of sharpening to apply to "flat" areas. Defaults to `1.0`.
198
-
* jagged: The level of sharpening to apply to "jagged" areas. Defaults to `2.0`.
199
221
222
+
-`sigma`: The sigma of the Gaussian mask. Defaults to `1`.
223
+
-`flat`: The level of sharpening to apply to "flat" areas. Defaults to `1.0`.
224
+
-`jagged`: The level of sharpening to apply to "jagged" areas. Defaults to `2.0`.
0 commit comments