UNPKG

9.51 kBtext/x-cView Raw
1// Copyright 2013 Lovell Fuller and others.
2// SPDX-License-Identifier: Apache-2.0
3
4#ifndef SRC_PIPELINE_H_
5#define SRC_PIPELINE_H_
6
7#include <memory>
8#include <string>
9#include <vector>
10#include <unordered_map>
11
12#include <napi.h>
13#include <vips/vips8>
14
15#include "./common.h"
16
17Napi::Value pipeline(const Napi::CallbackInfo& info);
18
19struct Composite {
20 sharp::InputDescriptor *input;
21 VipsBlendMode mode;
22 int gravity;
23 int left;
24 int top;
25 bool hasOffset;
26 bool tile;
27 bool premultiplied;
28
29 Composite():
30 input(nullptr),
31 mode(VIPS_BLEND_MODE_OVER),
32 gravity(0),
33 left(0),
34 top(0),
35 hasOffset(false),
36 tile(false),
37 premultiplied(false) {}
38};
39
40struct PipelineBaton {
41 sharp::InputDescriptor *input;
42 std::string formatOut;
43 std::string fileOut;
44 void *bufferOut;
45 size_t bufferOutLength;
46 int pageHeightOut;
47 int pagesOut;
48 std::vector<Composite *> composite;
49 std::vector<sharp::InputDescriptor *> joinChannelIn;
50 int topOffsetPre;
51 int leftOffsetPre;
52 int widthPre;
53 int heightPre;
54 int topOffsetPost;
55 int leftOffsetPost;
56 int widthPost;
57 int heightPost;
58 int width;
59 int height;
60 int channels;
61 VipsKernel kernel;
62 sharp::Canvas canvas;
63 int position;
64 std::vector<double> resizeBackground;
65 bool hasCropOffset;
66 int cropOffsetLeft;
67 int cropOffsetTop;
68 bool hasAttentionCenter;
69 int attentionX;
70 int attentionY;
71 bool premultiplied;
72 bool tileCentre;
73 bool fastShrinkOnLoad;
74 std::vector<double> tint;
75 bool flatten;
76 std::vector<double> flattenBackground;
77 bool unflatten;
78 bool negate;
79 bool negateAlpha;
80 double blurSigma;
81 VipsPrecision precision;
82 double minAmpl;
83 double brightness;
84 double saturation;
85 int hue;
86 double lightness;
87 int medianSize;
88 double sharpenSigma;
89 double sharpenM1;
90 double sharpenM2;
91 double sharpenX1;
92 double sharpenY2;
93 double sharpenY3;
94 int threshold;
95 bool thresholdGrayscale;
96 std::vector<double> trimBackground;
97 double trimThreshold;
98 bool trimLineArt;
99 int trimOffsetLeft;
100 int trimOffsetTop;
101 std::vector<double> linearA;
102 std::vector<double> linearB;
103 double gamma;
104 double gammaOut;
105 bool greyscale;
106 bool normalise;
107 int normaliseLower;
108 int normaliseUpper;
109 int claheWidth;
110 int claheHeight;
111 int claheMaxSlope;
112 bool useExifOrientation;
113 int angle;
114 double rotationAngle;
115 std::vector<double> rotationBackground;
116 bool rotateBeforePreExtract;
117 bool flip;
118 bool flop;
119 int extendTop;
120 int extendBottom;
121 int extendLeft;
122 int extendRight;
123 std::vector<double> extendBackground;
124 VipsExtend extendWith;
125 bool withoutEnlargement;
126 bool withoutReduction;
127 std::vector<double> affineMatrix;
128 std::vector<double> affineBackground;
129 double affineIdx;
130 double affineIdy;
131 double affineOdx;
132 double affineOdy;
133 std::string affineInterpolator;
134 int jpegQuality;
135 bool jpegProgressive;
136 std::string jpegChromaSubsampling;
137 bool jpegTrellisQuantisation;
138 int jpegQuantisationTable;
139 bool jpegOvershootDeringing;
140 bool jpegOptimiseScans;
141 bool jpegOptimiseCoding;
142 bool pngProgressive;
143 int pngCompressionLevel;
144 bool pngAdaptiveFiltering;
145 bool pngPalette;
146 int pngQuality;
147 int pngEffort;
148 int pngBitdepth;
149 double pngDither;
150 int jp2Quality;
151 bool jp2Lossless;
152 int jp2TileHeight;
153 int jp2TileWidth;
154 std::string jp2ChromaSubsampling;
155 int webpQuality;
156 int webpAlphaQuality;
157 bool webpNearLossless;
158 bool webpLossless;
159 bool webpSmartSubsample;
160 VipsForeignWebpPreset webpPreset;
161 int webpEffort;
162 bool webpMinSize;
163 bool webpMixed;
164 int gifBitdepth;
165 int gifEffort;
166 double gifDither;
167 double gifInterFrameMaxError;
168 double gifInterPaletteMaxError;
169 bool gifReuse;
170 bool gifProgressive;
171 int tiffQuality;
172 VipsForeignTiffCompression tiffCompression;
173 VipsForeignTiffPredictor tiffPredictor;
174 bool tiffPyramid;
175 int tiffBitdepth;
176 bool tiffMiniswhite;
177 bool tiffTile;
178 int tiffTileHeight;
179 int tiffTileWidth;
180 double tiffXres;
181 double tiffYres;
182 VipsForeignTiffResunit tiffResolutionUnit;
183 int heifQuality;
184 VipsForeignHeifCompression heifCompression;
185 int heifEffort;
186 std::string heifChromaSubsampling;
187 bool heifLossless;
188 int heifBitdepth;
189 double jxlDistance;
190 int jxlDecodingTier;
191 int jxlEffort;
192 bool jxlLossless;
193 VipsBandFormat rawDepth;
194 std::string err;
195 int keepMetadata;
196 int withMetadataOrientation;
197 double withMetadataDensity;
198 std::string withIccProfile;
199 std::unordered_map<std::string, std::string> withExif;
200 bool withExifMerge;
201 int timeoutSeconds;
202 std::vector<double> convKernel;
203 int convKernelWidth;
204 int convKernelHeight;
205 double convKernelScale;
206 double convKernelOffset;
207 sharp::InputDescriptor *boolean;
208 VipsOperationBoolean booleanOp;
209 VipsOperationBoolean bandBoolOp;
210 int extractChannel;
211 bool removeAlpha;
212 double ensureAlpha;
213 VipsInterpretation colourspacePipeline;
214 VipsInterpretation colourspace;
215 std::vector<int> delay;
216 int loop;
217 int tileSize;
218 int tileOverlap;
219 VipsForeignDzContainer tileContainer;
220 VipsForeignDzLayout tileLayout;
221 std::string tileFormat;
222 int tileAngle;
223 std::vector<double> tileBackground;
224 int tileSkipBlanks;
225 VipsForeignDzDepth tileDepth;
226 std::string tileId;
227 std::string tileBasename;
228 std::vector<double> recombMatrix;
229
230 PipelineBaton():
231 input(nullptr),
232 bufferOutLength(0),
233 pageHeightOut(0),
234 pagesOut(0),
235 topOffsetPre(-1),
236 topOffsetPost(-1),
237 channels(0),
238 kernel(VIPS_KERNEL_LANCZOS3),
239 canvas(sharp::Canvas::CROP),
240 position(0),
241 resizeBackground{ 0.0, 0.0, 0.0, 255.0 },
242 hasCropOffset(false),
243 cropOffsetLeft(0),
244 cropOffsetTop(0),
245 hasAttentionCenter(false),
246 attentionX(0),
247 attentionY(0),
248 premultiplied(false),
249 tint{ -1.0, 0.0, 0.0, 0.0 },
250 flatten(false),
251 flattenBackground{ 0.0, 0.0, 0.0 },
252 unflatten(false),
253 negate(false),
254 negateAlpha(true),
255 blurSigma(0.0),
256 brightness(1.0),
257 saturation(1.0),
258 hue(0),
259 lightness(0),
260 medianSize(0),
261 sharpenSigma(0.0),
262 sharpenM1(1.0),
263 sharpenM2(2.0),
264 sharpenX1(2.0),
265 sharpenY2(10.0),
266 sharpenY3(20.0),
267 threshold(0),
268 thresholdGrayscale(true),
269 trimBackground{},
270 trimThreshold(-1.0),
271 trimLineArt(false),
272 trimOffsetLeft(0),
273 trimOffsetTop(0),
274 linearA{},
275 linearB{},
276 gamma(0.0),
277 greyscale(false),
278 normalise(false),
279 normaliseLower(1),
280 normaliseUpper(99),
281 claheWidth(0),
282 claheHeight(0),
283 claheMaxSlope(3),
284 useExifOrientation(false),
285 angle(0),
286 rotationAngle(0.0),
287 rotationBackground{ 0.0, 0.0, 0.0, 255.0 },
288 flip(false),
289 flop(false),
290 extendTop(0),
291 extendBottom(0),
292 extendLeft(0),
293 extendRight(0),
294 extendBackground{ 0.0, 0.0, 0.0, 255.0 },
295 extendWith(VIPS_EXTEND_BACKGROUND),
296 withoutEnlargement(false),
297 withoutReduction(false),
298 affineMatrix{ 1.0, 0.0, 0.0, 1.0 },
299 affineBackground{ 0.0, 0.0, 0.0, 255.0 },
300 affineIdx(0),
301 affineIdy(0),
302 affineOdx(0),
303 affineOdy(0),
304 affineInterpolator("bicubic"),
305 jpegQuality(80),
306 jpegProgressive(false),
307 jpegChromaSubsampling("4:2:0"),
308 jpegTrellisQuantisation(false),
309 jpegQuantisationTable(0),
310 jpegOvershootDeringing(false),
311 jpegOptimiseScans(false),
312 jpegOptimiseCoding(true),
313 pngProgressive(false),
314 pngCompressionLevel(6),
315 pngAdaptiveFiltering(false),
316 pngPalette(false),
317 pngQuality(100),
318 pngEffort(7),
319 pngBitdepth(8),
320 pngDither(1.0),
321 jp2Quality(80),
322 jp2Lossless(false),
323 jp2TileHeight(512),
324 jp2TileWidth(512),
325 jp2ChromaSubsampling("4:4:4"),
326 webpQuality(80),
327 webpAlphaQuality(100),
328 webpNearLossless(false),
329 webpLossless(false),
330 webpSmartSubsample(false),
331 webpPreset(VIPS_FOREIGN_WEBP_PRESET_DEFAULT),
332 webpEffort(4),
333 webpMinSize(false),
334 webpMixed(false),
335 gifBitdepth(8),
336 gifEffort(7),
337 gifDither(1.0),
338 gifInterFrameMaxError(0.0),
339 gifInterPaletteMaxError(3.0),
340 gifReuse(true),
341 gifProgressive(false),
342 tiffQuality(80),
343 tiffCompression(VIPS_FOREIGN_TIFF_COMPRESSION_JPEG),
344 tiffPredictor(VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL),
345 tiffPyramid(false),
346 tiffBitdepth(8),
347 tiffMiniswhite(false),
348 tiffTile(false),
349 tiffTileHeight(256),
350 tiffTileWidth(256),
351 tiffXres(1.0),
352 tiffYres(1.0),
353 tiffResolutionUnit(VIPS_FOREIGN_TIFF_RESUNIT_INCH),
354 heifQuality(50),
355 heifCompression(VIPS_FOREIGN_HEIF_COMPRESSION_AV1),
356 heifEffort(4),
357 heifChromaSubsampling("4:4:4"),
358 heifLossless(false),
359 heifBitdepth(8),
360 jxlDistance(1.0),
361 jxlDecodingTier(0),
362 jxlEffort(7),
363 jxlLossless(false),
364 rawDepth(VIPS_FORMAT_UCHAR),
365 keepMetadata(0),
366 withMetadataOrientation(-1),
367 withMetadataDensity(0.0),
368 withExifMerge(true),
369 timeoutSeconds(0),
370 convKernelWidth(0),
371 convKernelHeight(0),
372 convKernelScale(0.0),
373 convKernelOffset(0.0),
374 boolean(nullptr),
375 booleanOp(VIPS_OPERATION_BOOLEAN_LAST),
376 bandBoolOp(VIPS_OPERATION_BOOLEAN_LAST),
377 extractChannel(-1),
378 removeAlpha(false),
379 ensureAlpha(-1.0),
380 colourspacePipeline(VIPS_INTERPRETATION_LAST),
381 colourspace(VIPS_INTERPRETATION_LAST),
382 loop(-1),
383 tileSize(256),
384 tileOverlap(0),
385 tileContainer(VIPS_FOREIGN_DZ_CONTAINER_FS),
386 tileLayout(VIPS_FOREIGN_DZ_LAYOUT_DZ),
387 tileAngle(0),
388 tileBackground{ 255.0, 255.0, 255.0, 255.0 },
389 tileSkipBlanks(-1),
390 tileDepth(VIPS_FOREIGN_DZ_DEPTH_LAST) {}
391};
392
393#endif // SRC_PIPELINE_H_