UNPKG

21.5 kBTypeScriptView Raw
1/// <reference types="node"/>
2
3import stream = require("stream");
4
5declare function m(stream: NodeJS.ReadableStream | Buffer | string, image?: string): m.State;
6declare function m(width: number, height: number, color?: string): m.State;
7
8declare namespace m {
9 interface ClassOptions {
10 appPath?: string | undefined;
11 imageMagick?: string | boolean | undefined;
12 nativeAutoOrient?: boolean | undefined;
13 timeout?: string | number;
14 }
15
16 interface ChannelInfo<T> {
17 Red: T;
18 Green: T;
19 Blue: T;
20 }
21
22 interface CompareOptions {
23 file?: string | undefined;
24 highlightColor?: string | undefined;
25 highlightStyle?: HighlightStyle | undefined;
26 tolerance?: number | undefined;
27 }
28
29 interface ColorStatistics {
30 Minimum: string;
31 Maximum: string;
32 Mean: string;
33 "Standard Deviation": string;
34 }
35
36 interface Dimensions {
37 width: number;
38 height: number;
39 }
40
41 interface GetterOptions {
42 bufferStream?: boolean | undefined;
43 }
44
45 interface ImageInfo {
46 "Background Color": string;
47 "Border Color": string;
48 "Channel Depths": ChannelInfo<string>;
49 "Channel Statistics": ChannelInfo<ColorStatistics>;
50 Class: string;
51 color: number;
52 Compose: string;
53 Compression: string;
54 depth: number;
55 Depth: string;
56 Dispose: string;
57 Filesize: string;
58 format: string;
59 Format: string;
60 Geometry: string;
61 Interlace: string;
62 Iterations: string;
63 "JPEG-Quality"?: string | undefined;
64 "JPEG-Colorspace"?: string | undefined;
65 "JPEG-Colorspace-Name"?: string | undefined;
66 "JPEG-Sampling-factors"?: string | undefined;
67 "Matte Color": string;
68 Orientation: string;
69 "Page geometry": string;
70 path: string;
71
72 "Profile-color"?: string | undefined;
73 "Profile-iptc"?: {
74 [key: string]: string;
75 } | undefined;
76 "Profile-EXIF"?: {
77 [key: string]: string;
78 } | undefined;
79 "Profile-XMP"?: string | undefined;
80 Resolution?: string | undefined;
81 size: Dimensions;
82 Signature: string;
83 Software: string;
84 Tainted: string;
85 Type: string;
86 }
87
88 interface State {
89 // Image Operations
90 adjoin(): State;
91 affine(matrix: string): State;
92 antialias(enable: boolean): State;
93 append(ltr?: boolean): State;
94 append(image: string | string[], ltr?: boolean): State;
95 authenticate(password: string): State;
96 autoOrient(): State;
97 average(): State;
98 backdrop(): State;
99 background(color: string): State;
100 bitdepth(bits: number): State;
101 blackThreshold(intensity: number): State;
102 blackThreshold(red: number, green: number, blue: number, opacity?: number): State;
103 bluePrimary(x: number, y: number): State;
104 blur(radius: number, sigma?: number): State;
105 border(width: number, height: number): State;
106 borderColor(color: string): State;
107 box(color: string): State;
108 channel(type: NamedColor | string): State;
109 charcoal(factor: number): State;
110 chop(width: number, height: number, x?: number, y?: number): State;
111 clip(): State;
112 coalesce(): State;
113 colorize(red: number, green: number, blue: number): State;
114 colorMap(type: "shared" | "private" | string): State;
115 colors(colors: number): State;
116 colorspace(space: ColorSpace | string): State;
117 command(customCommand: string): State;
118 compose(operator: ComposeOperator | string): State;
119 composite(changeImagePath: string, maskImagePath?: string): State;
120 compress(type: CompressionType | string): State;
121 contrast(multiplier: number): State;
122 convolve(kernel: string): State;
123 createDirectories(): State;
124 crop(width: number, height: number, x?: number, y?: number, percent?: boolean): State;
125 cycle(amount: number): State;
126 deconstruct(): State;
127 define(value: string): State;
128 delay(centiseconds: number): State;
129 density(width: number, height: number): State;
130 despeckle(): State;
131 displace(horizontal: number, vertical: number): State;
132 display(xServer: string): State;
133 dispose(method: DisposeMethod | string): State;
134 dissolve(percent: number): State;
135 dither(enable?: boolean): State;
136 edge(radius?: number): State;
137 emboss(radius?: number): State;
138 encoding(encoding: Encoding | string): State;
139 endian(type: EndianType | string): State;
140 enhance(): State;
141 equalize(): State;
142 extent(width: number, height: number, options?: string): State;
143 file(filename: string): State;
144 filter(type: FilterType | string): State;
145 flatten(): State;
146 flip(): State;
147 flop(): State;
148 foreground(color: string): State;
149 frame(width: number, height: number, outerBevelWidth: number, outBevelHeight: number): State;
150 fuzz(distance: number, percent?: boolean): State;
151 gamma(r: number, g: number, b: number): State;
152 gaussian(radius: number, sigma?: number): State;
153 geometry(width: number, height?: number, option?: ResizeOption): State;
154 geometry(geometry: string): State;
155 greenPrimary(x: number, y: number): State;
156 gravity(direction: GravityDirection | string): State;
157 highlightColor(color: string): State;
158 highlightStyle(style: HighlightStyle | string): State;
159 iconGeometry(geometry: string): State;
160 implode(factor?: number): State;
161 in(...customArguments: string[]): State;
162 intent(type: IntentType | string): State;
163 interlace(type: InterlaceType | string): State;
164 label(name: string): State;
165 lat(width: number, height: number, offset: number, percent?: boolean): State;
166 level(blackPoint: number, gamma: number, whitePoint: number, percent?: boolean): State;
167 limit(type: LimitType | string, val: string): State;
168 list(type: ListType | string): State;
169 log(format: string): State;
170 loop(iterations: number): State;
171 lower(width: number, height: number): State;
172 magnify(factor: number): State;
173 map(filename: string): State;
174 mask(filename: string): State;
175 matte(): State;
176 matteColor(color: string): State;
177 maximumError(limit: number): State;
178 median(radius?: number): State;
179 minify(factor: number): State;
180 mode(mode: OperationMode | string): State;
181 modulate(b: number, s?: number, h?: number): State;
182 monitor(): State;
183 monochrome(): State;
184 montage(otherImg: string): State;
185 morph(otherImg: string | string[], outName: string, callback?: WriteCallback): State;
186 mosaic(): State;
187 motionBlur(radius: number, sigma?: number, angle?: number): State;
188 name(): State;
189 negative(): State;
190 noise(type: NoiseType | string | number): State;
191 noop(): State;
192 normalize(): State;
193 opaque(color: string): State;
194 operator(channel: string, operator: ChannelOperator | string, rvalue: number, percent?: boolean): State;
195 orderedDither(channelType: ChannelType | string, NxN: string): State;
196 out(...customArguments: string[]): State;
197 outputDirectory(directory: string): State;
198 page(width: number, height: number, arg?: "%" | "!" | "<" | ">" | string): State;
199 pause(seconds: number): State;
200 pen(color: string): State;
201 ping(): State;
202 pointSize(size: number): State;
203 noProfile(): State;
204 preview(type: PreviewType | string): State;
205 paint(radius: number): State;
206 process(command: string): State;
207 profile(filename: string): State;
208 progress(): State;
209 randomThreshold(channelType: ChannelType, LOWxHIGH: string): State;
210 quality(level: number): State;
211 raise(width: number, height: number): State;
212 recolor(matrix: string): State;
213 redPrimary(x: number, y: number): State;
214 region(width: number, height: number, x?: number, y?: number): State;
215 remote(): State;
216 render(): State;
217 repage(reset: "+" | string): State;
218 repage(width: number, height: number, xoff: number, yoff: number, arg?: string): State;
219 sample(geometry: string): State;
220 samplingFactor(horizontalFactor: number, verticalFactor: number): State;
221 rawSize(width: number, height: number, offset?: number): State;
222 resample(horizontal: number, vertical: number): State;
223 resize(width: number, height: number, option: ResizeOption): State;
224 resize(width: number, height?: number, option?: ResizeOption): State;
225 roll(horizontal: number, vertical: number): State;
226 rotate(backgroundColor: string, degrees: number): State;
227 scene(index: number): State;
228 scenes(start: number, end: number): State;
229 scale(width: number, height: number): State;
230 screen(): State;
231 segment(clustherThreshold: number, smoothingThreshold: number): State;
232 /** change the specified frame. */
233 selectFrame(frame: number): State;
234 sepia(): State;
235 set(attribute: string, value: string): State;
236 setFormat(format: string): State;
237 shade(azimuth: number, elevation: number): State;
238 shadow(radius: number, sigma?: number): State;
239 sharedMemory(): State;
240 shave(width: number, height: number, percent?: boolean): State;
241 sharpen(radius: number, sigma?: number): State;
242 shear(xDegrees: number, yDegress: number): State;
243 silent(): State;
244 snaps(count: number): State;
245 solarize(threshold: number): State;
246 spread(amount: number): State;
247 stegano(offset: number): State;
248 stereo(): State;
249 strip(): State;
250 swirl(degrees: number): State;
251 textFont(font: string): State;
252 texture(filename: string): State;
253 threshold(value: number, percent?: boolean): State;
254 thumb(width: number, height: number, outName: string, callback: WriteCallback): State;
255 thumb(width: number, height: number, outName: string, quality: number, callback: WriteCallback): State;
256 thumb(
257 width: number,
258 height: number,
259 outName: string,
260 quality: number,
261 align: "topleft" | "center" | string,
262 callback: WriteCallback,
263 ): State;
264 thumbnail(width: number, height: number, options?: ResizeOption): State;
265 tile(filename: string): State;
266 title(title: string): State;
267 transform(color: string): State;
268 transparent(color: string): State;
269 treeDepth(depth: number): State;
270 trim(): State;
271 type(type: ImageType | string): State;
272 update(seconds: number): State;
273 units(type: UnitType | string): State;
274 unsharp(radius: number, sigma?: number, amount?: number, threshold?: number): State;
275 usePixmap(): State;
276 view(): State;
277 virtualPixel(method: VirtualPixelMethod | string): State;
278 visual(type: VisualType | string): State;
279 watermark(brightness: number, saturation: number): State;
280 wave(amplitude: number, wavelength: number): State;
281 whitePoint(x: number, y: number): State;
282 whiteThreshold(intensity: number): State;
283 whiteThreshold(red: number, green: number, blue: number, opacity?: number): State;
284 window(id: string): State;
285 windowGroup(): State;
286
287 // Getters
288 color(callback: GetterCallback<number>): State;
289 color(opts: GetterOptions, callback: GetterCallback<number>): State;
290 depth(callback: GetterCallback<number>): State;
291 depth(opts: GetterOptions, callback: GetterCallback<number>): State;
292 filesize(callback: GetterCallback<string>): State;
293 filesize(opts: GetterOptions, callback: GetterCallback<string>): State;
294 format(callback: GetterCallback<string>): State;
295 format(opts: GetterOptions, callback: GetterCallback<string>): State;
296 identify(callback: GetterCallback<ImageInfo>): State;
297 identify(format: string, callback: GetterCallback<string>): State;
298 identify(opts: GetterOptions, callback: GetterCallback<ImageInfo>): State;
299 res(callback: GetterCallback<string>): State;
300 res(opts: GetterOptions, callback: GetterCallback<string>): State;
301 size(callback: GetterCallback<Dimensions>): State;
302 size(opts: GetterOptions, callback: GetterCallback<Dimensions>): State;
303 orientation(callback: GetterCallback<string>): State;
304 orientation(opts: GetterOptions, callback: GetterCallback<string>): State;
305
306 // Drawing Operations
307 draw(args: string): State;
308 drawArc(x0: number, y0: number, x1: number, y1: number, r0: number, r1: number): State;
309 drawBezier(coord0: [number, number], coord1: [number, number], ...coords: Array<[number, number]>): State;
310 drawCircle(x0: number, y0: number, x1: number, y1: number): State;
311 drawEllipse(x0: number, y0: number, rx: number, ry: number, a0: number, a1: number): State;
312 drawLine(x0: number, y0: number, x1: number, y1: number): State;
313 drawPoint(x: number, y: number): State;
314 drawPolygon(
315 coord0: [number, number],
316 coord1: [number, number],
317 coord2: [number, number],
318 ...coords: Array<[number, number]>
319 ): State;
320 drawPolyline(
321 coord0: [number, number],
322 coord1: [number, number],
323 coord2: [number, number],
324 ...coords: Array<[number, number]>
325 ): State;
326 drawRectangle(x0: number, y0: number, x1: number, y1: number, wc?: number, hc?: number): State;
327 drawText(x: number, y: number, text: string, gravity?: GravityDirection | string): State;
328 fill(color: string): State;
329 font(name: string, size?: number): State;
330 fontSize(size: number): State;
331 stroke(color: string, width?: number): State;
332 strokeWidth(width: number): State;
333 setDraw(property: SetDrawProperty | string, x: number, y: number, method: SetDrawMethod | string): State;
334
335 // Commands
336 stream(callback?: WriteCallback): stream.PassThrough;
337 stream(format: string, callback?: WriteCallback): stream.PassThrough;
338 toBuffer(callback: (err: Error | null, buffer: Buffer) => any): stream.PassThrough;
339 toBuffer(format: string, callback: (err: Error | null, buffer: Buffer) => any): stream.PassThrough;
340 write(filename: string, callback: WriteCallback): void;
341 }
342
343 interface SubClass {
344 (image: string): State;
345 (stream: NodeJS.ReadableStream | Buffer, image?: string): State;
346 (width: number, height: number, color?: string): State;
347 }
348
349 function compare(filename1: string, filename2: string, callback: CompareCallback): void;
350 function compare(
351 filename1: string,
352 filename2: string,
353 options: CompareOptions | number,
354 callback: CompareCallback,
355 ): void;
356
357 function subClass(options: ClassOptions): SubClass;
358
359 type ChannelOperator =
360 | "Add"
361 | "And"
362 | "Assign"
363 | "Depth"
364 | "Divide"
365 | "Gamma"
366 | "Negate"
367 | "LShift"
368 | "Log"
369 | "Max"
370 | "Min"
371 | "Multiply"
372 | "Or"
373 | "Pow"
374 | "RShift"
375 | "Subtract"
376 | "Threshold"
377 | "Threshold-White"
378 | "Threshold-White-Negate"
379 | "Threshold-Black"
380 | "Threshold-Black-Negate"
381 | "Xor"
382 | "Noise-Gaussian"
383 | "Noise-Impulse"
384 | "Noise-Laplacian"
385 | "Noise-Multiplicative"
386 | "Noise-Poisson"
387 | "Noise-Random"
388 | "Noise-Uniform";
389
390 type ChannelType =
391 | "All"
392 | "Intensity"
393 | "Red"
394 | "Green"
395 | "Blue"
396 | "Cyan"
397 | "Magenta"
398 | "Yellow"
399 | "Black"
400 | "Opacity";
401
402 type ColorSpace =
403 | "CineonLog"
404 | "CMYK"
405 | "GRAY"
406 | "HSL"
407 | "HSB"
408 | "OHTA"
409 | "RGB"
410 | "Rec601Luma"
411 | "Rec709Luma"
412 | "Rec601YCbCr"
413 | "Rec709YCbCr"
414 | "Transparent"
415 | "XYZ"
416 | "YCbCr"
417 | "YIQ"
418 | "YPbPr"
419 | "YUV";
420
421 type CompareCallback = (err: Error | null, isEqual: boolean, equality: number, raw: number) => any;
422
423 type ComposeOperator =
424 | "Over"
425 | "In"
426 | "Out"
427 | "Atop"
428 | "Xor"
429 | "Plus"
430 | "Minus"
431 | "Add"
432 | "Subtract"
433 | "Difference"
434 | "Divide"
435 | "Multiply"
436 | "Bumpmap"
437 | "Copy"
438 | "CopyRed"
439 | "CopyGreen"
440 | "CopyBlue"
441 | "CopyOpacity"
442 | "CopyCyan"
443 | "CopyMagenta"
444 | "CopyYellow"
445 | "CopyBlack";
446
447 type CompressionType =
448 | "None"
449 | "BZip"
450 | "Fax"
451 | "Group4"
452 | "JPEG"
453 | "Lossless"
454 | "LZW"
455 | "RLE"
456 | "Zip"
457 | "LZMA";
458
459 type DisposeMethod =
460 | "Undefined"
461 | "None"
462 | "Background"
463 | "Previous";
464
465 type Encoding =
466 | "AdobeCustom"
467 | "AdobeExpert"
468 | "AdobeStandard"
469 | "AppleRoman"
470 | "BIG5"
471 | "GB2312"
472 | "Latin 2"
473 | "None"
474 | "SJIScode"
475 | "Symbol"
476 | "Unicode"
477 | "Wansung";
478
479 type EndianType =
480 | "MSB"
481 | "LSB"
482 | "Native";
483
484 type FilterType =
485 | "Point"
486 | "Box"
487 | "Triangle"
488 | "Hermite"
489 | "Hanning"
490 | "Hamming"
491 | "Blackman"
492 | "Gaussian"
493 | "Quadratic"
494 | "Cubic"
495 | "Catrom"
496 | "Mitchell"
497 | "Lanczos"
498 | "Bessel"
499 | "Sinc";
500
501 type GetterCallback<T> = (err: Error | null, value: T) => any;
502
503 type GravityDirection =
504 | "NorthWest"
505 | "North"
506 | "NorthEast"
507 | "West"
508 | "Center"
509 | "East"
510 | "SouthWest"
511 | "South"
512 | "SouthEast";
513
514 type HighlightStyle =
515 | "Assign"
516 | "Threshold"
517 | "Tint"
518 | "XOR";
519
520 type ImageType =
521 | "Bilevel"
522 | "Grayscale"
523 | "Palette"
524 | "PaletteMatte"
525 | "TrueColor"
526 | "TrueColorMatte"
527 | "ColorSeparation"
528 | "ColorSeparationMatte"
529 | "Optimize";
530
531 type IntentType =
532 | "Absolute"
533 | "Perceptual"
534 | "Relative"
535 | "Saturation";
536
537 type InterlaceType =
538 | "None"
539 | "Line"
540 | "Plane"
541 | "Partition";
542
543 type LimitType =
544 | "disk"
545 | "file"
546 | "map"
547 | "memory"
548 | "pixels"
549 | "threads";
550
551 type ListType =
552 | "Color"
553 | "Delegate"
554 | "Format"
555 | "Magic"
556 | "Module"
557 | "Resource"
558 | "Type";
559
560 type NamedColor =
561 | "Red"
562 | "Green"
563 | "Blue"
564 | "Opacity"
565 | "Matte"
566 | "Cyan"
567 | "Magenta"
568 | "Yellow"
569 | "Black"
570 | "Gray";
571
572 type NoiseType =
573 | "uniform"
574 | "gaussian"
575 | "multiplicative"
576 | "impulse"
577 | "laplacian"
578 | "poisson";
579
580 type OperationMode =
581 | "frame"
582 | "unframe"
583 | "concatenate";
584
585 type PreviewType =
586 | "Rotate"
587 | "Shear"
588 | "Roll"
589 | "Hue"
590 | "Saturation"
591 | "Brightness"
592 | "Gamma"
593 | "Spiff"
594 | "Dull"
595 | "Grayscale"
596 | "Quantize"
597 | "Despeckle"
598 | "ReduceNoise"
599 | "AddNoise"
600 | "Sharpen"
601 | "Blur"
602 | "Threshold"
603 | "EdgeDetect"
604 | "Spread"
605 | "Shade"
606 | "Raise"
607 | "Segment"
608 | "Solarize"
609 | "Swirl"
610 | "Implode"
611 | "Wave"
612 | "OilPaint"
613 | "CharcoalDrawing"
614 | "JPEG";
615
616 type ResizeOption =
617 | "%" /** Width and height are specified in percents */
618 | "@" /** Specify maximum area in pixels */
619 | "!" /** Ignore aspect ratio */
620 | "^" /** Width and height are minimum values */
621 | "<" /** Change dimensions only if image is smaller than width or height */
622 | ">"; /** Change dimensions only if image is larger than width or height */
623
624 type SetDrawMethod =
625 | "point"
626 | "replace"
627 | "floodfill"
628 | "filltoborder"
629 | "reset";
630
631 type SetDrawProperty = "color" | "matte";
632
633 type UnitType =
634 | "Undefined"
635 | "PixelsPerInch"
636 | "PixelsPerCentimeter";
637
638 type VirtualPixelMethod =
639 | "Constant"
640 | "Edge"
641 | "Mirror"
642 | "Tile";
643
644 type VisualType =
645 | "StaticGray"
646 | "GrayScale"
647 | "StaticColor"
648 | "PseudoColor"
649 | "TrueColor"
650 | "DirectColor"
651 | "default";
652
653 type WriteCallback = (err: Error | null, stdout: stream.Readable, stderr: stream.Readable, cmd: string) => any;
654}
655
656export = m;