1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | #ifndef SRC_PIPELINE_H_
|
16 | #define SRC_PIPELINE_H_
|
17 |
|
18 | #include <memory>
|
19 | #include <string>
|
20 | #include <vector>
|
21 |
|
22 | #include <napi.h>
|
23 | #include <vips/vips8>
|
24 |
|
25 | #include "./common.h"
|
26 |
|
27 | Napi::Value pipeline(const Napi::CallbackInfo& info);
|
28 |
|
29 | enum class Canvas {
|
30 | CROP,
|
31 | EMBED,
|
32 | MAX,
|
33 | MIN,
|
34 | IGNORE_ASPECT
|
35 | };
|
36 |
|
37 | struct Composite {
|
38 | sharp::InputDescriptor *input;
|
39 | VipsBlendMode mode;
|
40 | int gravity;
|
41 | int left;
|
42 | int top;
|
43 | bool tile;
|
44 | bool premultiplied;
|
45 |
|
46 | Composite():
|
47 | input(nullptr),
|
48 | mode(VIPS_BLEND_MODE_OVER),
|
49 | gravity(0),
|
50 | left(-1),
|
51 | top(-1),
|
52 | tile(false),
|
53 | premultiplied(false) {}
|
54 | };
|
55 |
|
56 | struct PipelineBaton {
|
57 | sharp::InputDescriptor *input;
|
58 | std::string formatOut;
|
59 | std::string fileOut;
|
60 | void *bufferOut;
|
61 | size_t bufferOutLength;
|
62 | std::vector<Composite *> composite;
|
63 | std::vector<sharp::InputDescriptor *> joinChannelIn;
|
64 | int topOffsetPre;
|
65 | int leftOffsetPre;
|
66 | int widthPre;
|
67 | int heightPre;
|
68 | int topOffsetPost;
|
69 | int leftOffsetPost;
|
70 | int widthPost;
|
71 | int heightPost;
|
72 | int width;
|
73 | int height;
|
74 | int channels;
|
75 | Canvas canvas;
|
76 | int position;
|
77 | std::vector<double> resizeBackground;
|
78 | bool hasCropOffset;
|
79 | int cropOffsetLeft;
|
80 | int cropOffsetTop;
|
81 | bool premultiplied;
|
82 | std::string kernel;
|
83 | bool fastShrinkOnLoad;
|
84 | double tintA;
|
85 | double tintB;
|
86 | bool flatten;
|
87 | std::vector<double> flattenBackground;
|
88 | bool negate;
|
89 | double blurSigma;
|
90 | double brightness;
|
91 | double saturation;
|
92 | int hue;
|
93 | int medianSize;
|
94 | double sharpenSigma;
|
95 | double sharpenFlat;
|
96 | double sharpenJagged;
|
97 | int threshold;
|
98 | bool thresholdGrayscale;
|
99 | double trimThreshold;
|
100 | int trimOffsetLeft;
|
101 | int trimOffsetTop;
|
102 | double linearA;
|
103 | double linearB;
|
104 | double gamma;
|
105 | double gammaOut;
|
106 | bool greyscale;
|
107 | bool normalise;
|
108 | bool useExifOrientation;
|
109 | int angle;
|
110 | double rotationAngle;
|
111 | std::vector<double> rotationBackground;
|
112 | bool rotateBeforePreExtract;
|
113 | bool flip;
|
114 | bool flop;
|
115 | int extendTop;
|
116 | int extendBottom;
|
117 | int extendLeft;
|
118 | int extendRight;
|
119 | std::vector<double> extendBackground;
|
120 | bool withoutEnlargement;
|
121 | int jpegQuality;
|
122 | bool jpegProgressive;
|
123 | std::string jpegChromaSubsampling;
|
124 | bool jpegTrellisQuantisation;
|
125 | int jpegQuantisationTable;
|
126 | bool jpegOvershootDeringing;
|
127 | bool jpegOptimiseScans;
|
128 | bool jpegOptimiseCoding;
|
129 | bool pngProgressive;
|
130 | int pngCompressionLevel;
|
131 | bool pngAdaptiveFiltering;
|
132 | bool pngPalette;
|
133 | int pngQuality;
|
134 | int pngColours;
|
135 | double pngDither;
|
136 | int webpQuality;
|
137 | int webpAlphaQuality;
|
138 | bool webpNearLossless;
|
139 | bool webpLossless;
|
140 | bool webpSmartSubsample;
|
141 | int webpReductionEffort;
|
142 | int tiffQuality;
|
143 | VipsForeignTiffCompression tiffCompression;
|
144 | VipsForeignTiffPredictor tiffPredictor;
|
145 | bool tiffPyramid;
|
146 | bool tiffSquash;
|
147 | bool tiffTile;
|
148 | int tiffTileHeight;
|
149 | int tiffTileWidth;
|
150 | double tiffXres;
|
151 | double tiffYres;
|
152 | int heifQuality;
|
153 | VipsForeignHeifCompression heifCompression;
|
154 | bool heifLossless;
|
155 | std::string err;
|
156 | bool withMetadata;
|
157 | int withMetadataOrientation;
|
158 | std::unique_ptr<double[]> convKernel;
|
159 | int convKernelWidth;
|
160 | int convKernelHeight;
|
161 | double convKernelScale;
|
162 | double convKernelOffset;
|
163 | sharp::InputDescriptor *boolean;
|
164 | VipsOperationBoolean booleanOp;
|
165 | VipsOperationBoolean bandBoolOp;
|
166 | int extractChannel;
|
167 | bool removeAlpha;
|
168 | bool ensureAlpha;
|
169 | VipsInterpretation colourspace;
|
170 | int tileSize;
|
171 | int tileOverlap;
|
172 | VipsForeignDzContainer tileContainer;
|
173 | VipsForeignDzLayout tileLayout;
|
174 | std::string tileFormat;
|
175 | int tileAngle;
|
176 | std::vector<double> tileBackground;
|
177 | int tileSkipBlanks;
|
178 | VipsForeignDzDepth tileDepth;
|
179 | std::unique_ptr<double[]> recombMatrix;
|
180 |
|
181 | PipelineBaton():
|
182 | input(nullptr),
|
183 | bufferOutLength(0),
|
184 | topOffsetPre(-1),
|
185 | topOffsetPost(-1),
|
186 | channels(0),
|
187 | canvas(Canvas::CROP),
|
188 | position(0),
|
189 | resizeBackground{ 0.0, 0.0, 0.0, 255.0 },
|
190 | hasCropOffset(false),
|
191 | cropOffsetLeft(0),
|
192 | cropOffsetTop(0),
|
193 | premultiplied(false),
|
194 | tintA(128.0),
|
195 | tintB(128.0),
|
196 | flatten(false),
|
197 | flattenBackground{ 0.0, 0.0, 0.0 },
|
198 | negate(false),
|
199 | blurSigma(0.0),
|
200 | brightness(1.0),
|
201 | saturation(1.0),
|
202 | hue(0),
|
203 | medianSize(0),
|
204 | sharpenSigma(0.0),
|
205 | sharpenFlat(1.0),
|
206 | sharpenJagged(2.0),
|
207 | threshold(0),
|
208 | thresholdGrayscale(true),
|
209 | trimThreshold(0.0),
|
210 | trimOffsetLeft(0),
|
211 | trimOffsetTop(0),
|
212 | linearA(1.0),
|
213 | linearB(0.0),
|
214 | gamma(0.0),
|
215 | greyscale(false),
|
216 | normalise(false),
|
217 | useExifOrientation(false),
|
218 | angle(0),
|
219 | rotationAngle(0.0),
|
220 | rotationBackground{ 0.0, 0.0, 0.0, 255.0 },
|
221 | flip(false),
|
222 | flop(false),
|
223 | extendTop(0),
|
224 | extendBottom(0),
|
225 | extendLeft(0),
|
226 | extendRight(0),
|
227 | extendBackground{ 0.0, 0.0, 0.0, 255.0 },
|
228 | withoutEnlargement(false),
|
229 | jpegQuality(80),
|
230 | jpegProgressive(false),
|
231 | jpegChromaSubsampling("4:2:0"),
|
232 | jpegTrellisQuantisation(false),
|
233 | jpegQuantisationTable(0),
|
234 | jpegOvershootDeringing(false),
|
235 | jpegOptimiseScans(false),
|
236 | jpegOptimiseCoding(true),
|
237 | pngProgressive(false),
|
238 | pngCompressionLevel(9),
|
239 | pngAdaptiveFiltering(false),
|
240 | pngPalette(false),
|
241 | pngQuality(100),
|
242 | pngColours(256),
|
243 | pngDither(1.0),
|
244 | webpQuality(80),
|
245 | webpAlphaQuality(100),
|
246 | webpNearLossless(false),
|
247 | webpLossless(false),
|
248 | webpSmartSubsample(false),
|
249 | webpReductionEffort(4),
|
250 | tiffQuality(80),
|
251 | tiffCompression(VIPS_FOREIGN_TIFF_COMPRESSION_JPEG),
|
252 | tiffPredictor(VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL),
|
253 | tiffPyramid(false),
|
254 | tiffSquash(false),
|
255 | tiffTile(false),
|
256 | tiffTileHeight(256),
|
257 | tiffTileWidth(256),
|
258 | tiffXres(1.0),
|
259 | tiffYres(1.0),
|
260 | heifQuality(80),
|
261 | heifCompression(VIPS_FOREIGN_HEIF_COMPRESSION_HEVC),
|
262 | heifLossless(false),
|
263 | withMetadata(false),
|
264 | withMetadataOrientation(-1),
|
265 | convKernelWidth(0),
|
266 | convKernelHeight(0),
|
267 | convKernelScale(0.0),
|
268 | convKernelOffset(0.0),
|
269 | boolean(nullptr),
|
270 | booleanOp(VIPS_OPERATION_BOOLEAN_LAST),
|
271 | bandBoolOp(VIPS_OPERATION_BOOLEAN_LAST),
|
272 | extractChannel(-1),
|
273 | removeAlpha(false),
|
274 | ensureAlpha(false),
|
275 | colourspace(VIPS_INTERPRETATION_LAST),
|
276 | tileSize(256),
|
277 | tileOverlap(0),
|
278 | tileContainer(VIPS_FOREIGN_DZ_CONTAINER_FS),
|
279 | tileLayout(VIPS_FOREIGN_DZ_LAYOUT_DZ),
|
280 | tileAngle(0),
|
281 | tileBackground{ 255.0, 255.0, 255.0, 255.0 },
|
282 | tileSkipBlanks(-1),
|
283 | tileDepth(VIPS_FOREIGN_DZ_DEPTH_LAST) {}
|
284 | };
|
285 |
|
286 | #endif
|