-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
vips.d.ts
9631 lines (9103 loc) · 261 KB
/
vips.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
declare function Vips(config?: Partial<EmscriptenModule>): Promise<NonNullable<typeof Vips>>;
type ModuleCallback = { (module?: any): void };
interface EmscriptenModule {
print(str: string): void;
printErr(str: string): void;
preInit: ModuleCallback | ModuleCallback[];
preRun: ModuleCallback | ModuleCallback[];
postRun: ModuleCallback | ModuleCallback[];
onAbort: { (what: any): void };
onRuntimeInitialized: { (): void };
instantiateWasm(
imports: WebAssembly.Imports,
successCallback: (instance: WebAssembly.Instance, module: WebAssembly.Module) => void
): WebAssembly.Exports;
locateFile(url: string, scriptDirectory: string): string;
mainScriptUrlOrBlob: Blob | File | string;
}
declare module Vips {
// Allow single pixels/images as input.
type SingleOrArray<T> = T | T[];
type Enum = string | number;
type Flag = string | number;
type Blob = string | ArrayBuffer | Uint8Array | Uint8ClampedArray | Int8Array;
type ArrayConstant = SingleOrArray<number>;
type ArrayImage = SingleOrArray<Image> | Vector<Image>;
type DeletionFuncs<T extends EmbindClassHandle<T>> = EmbindClassHandle<T>[];
//#region Utility functions
/**
* Queue of handles to be deleted.
* This is filled when [[deleteLater]] is called on the handle.
*/
const deletionQueue: DeletionFuncs<Image | Connection | Interpolate>;
/**
* Get the major, minor or patch version number of the libvips library.
* When the flag is omitted, the entire version number is returned as a string.
* @param flag 0 to get the major version number, 1 to get minor, 2 to get patch.
* @return The version number of libvips.
*/
function version(flag?: number): string | number;
/**
* Returns a string identifying the Emscripten version used for compiling wasm-vips.
* @return The version number of Emscripten.
*/
function emscriptenVersion(): string;
/**
* Get detailed information about the installation of libvips.
* @return Information about how libvips is configured.
*/
function config(): string;
/**
* Gets or, when a parameter is provided, sets the number of worker threads libvips' should create to
* process each image.
* @param concurrency The number of worker threads.
* @return The number of worker threads libvips uses for image evaluation.
*/
function concurrency(concurrency?: number): void | number;
/**
* Call this to shutdown libvips and the runtime of Emscripten.
* This is only needed on Node.js, as the thread pool of
* Emscripten prevents the event loop from exiting.
*/
function shutdown(): void;
/**
* Convert a bigint value (usually coming from Wasm->JS call) into an int53 JS Number.
* This is used when we have an incoming i64 that we know is a pointer or size_t and
* is expected to be withing the int53 range.
* @return The converted bigint value or NaN if the incoming bigint is outside the range.
*/
function bigintToI53Checked(num: bigint): number;
//#endregion
//#region APIs
/**
* Embind adds the following methods to all its exposed classes.
*/
abstract class EmbindClassHandle<T extends EmbindClassHandle<T>> {
/**
* Returns a new handle. It must eventually also be disposed with [[delete]] or
* [[deleteLater]].
* @return A new handle.
*/
clone(): T;
/**
* Signal that a C++ object is no longer needed and can be deleted.
*/
delete(): void;
/**
* Signal that a C++ object is no longer needed and can be deleted later.
*/
deleteLater(): void;
/**
* Check whether two Embind handles point to the same underlying object.
* @param other Embind handle for comparison.
* @return `true` if the handles point to the same underlying object.
*/
isAliasOf(other: any): boolean;
/**
* Check whether this handle is deleted.
* @return `true` if this handle is deleted.
*/
isDeleted(): boolean;
}
/**
* A sequence container representing an array that can change in size.
*/
interface Vector<T> extends EmbindClassHandle<Vector<T>> {
/**
* Adds a new element at the end of the vector, after its current last element.
* @param val The value to be appended at the end of the container.
*/
push_back(val: T): void;
/**
* Resizes the container so that it contains n elements.
* @param n New size of the container.
* @param val The value to initialize the new elements with.
*/
resize(n: number, val: T): void;
/**
* Returns the number of elements in the container.
* @return The number of elements in the container.
*/
size(): number;
/**
* Access a specified element with bounds checking.
* @param pos Position of the element to return.
* @return The requested element or `undefined`.
*/
get(pos: number): T | undefined;
/**
* Update a specified element at a certain position.
* @param pos Position of the element to update.
* @param val Value to be stored at the specified position.
* @return `true` if successfully updated.
*/
set(pos: number, val: T): boolean;
}
/**
* An abstract class around libvips' operation cache.
*/
abstract class Cache {
/**
* Gets or, when a parameter is provided, sets the maximum number of operations libvips keeps in cache.
* @param max Maximum number of operations.
* @return The maximum number of operations libvips keeps in cache.
*/
static max(max?: number): void | number;
/**
* Gets or, when a parameter is provided, sets the maximum amount of tracked memory allowed.
* @param mem Maximum amount of tracked memory.
* @return The maximum amount of tracked memory libvips allows.
*/
static maxMem(mem?: number): void | number;
/**
* Gets or, when a parameter is provided, sets the maximum amount of tracked files allowed.
* @param maxFiles Maximum amount of tracked files.
* @return The maximum amount of tracked files libvips allows.
*/
static maxFiles(maxFiles?: number): void | number;
/**
* Get the current number of operations in cache.
* @return The current number of operations in cache.
*/
static size(): number;
}
/**
* An abstract class that provides the statistics of memory usage and opened files.
* libvips watches the total amount of live tracked memory and
* uses this information to decide when to trim caches.
*/
abstract class Stats {
/**
* Get the number of active allocations.
* @return The number of active allocations.
*/
static allocations(): number;
/**
* Get the number of bytes currently allocated `vips_malloc()` and friends.
* libvips uses this figure to decide when to start dropping cache.
* @return The number of bytes currently allocated.
*/
static mem(): number;
/**
* Get the largest number of bytes simultaneously allocated via `vips_tracked_malloc()`.
* Handy for estimating max memory requirements for a program.
* @return The largest number of currently allocated bytes.
*/
static memHighwater(): number;
/**
* Get the number of open files.
* @return The number of open files.
*/
static files(): number;
}
/**
* An abstract class for error messages and error handling.
*/
abstract class Error {
/**
* Get the error buffer as a string.
* @return The error buffer as a string.
*/
static buffer(): string;
/**
* Clear and reset the error buffer.
* This is typically called after presenting an error to the user.
*/
static clear(): void;
}
/**
* Handy utilities.
*/
abstract class Utils {
/**
* Get the GType for a name.
* Looks up the GType for a nickname. Types below basename in the type hierarchy are searched.
* @param basename Name of base class.
* @param nickname Search for a class with this nickname.
* @return The GType of the class, or `0` if the class is not found.
*/
static typeFind(basename: string, nickname: string): number;
/**
* Make a temporary file name. The format parameter is something like `"%s.jpg"`
* and will be expanded to something like `"/tmp/vips-12-34587.jpg"`.
* @param format The filename format.
*/
static tempName(format: string): string;
}
/**
* The abstract base Connection class.
*/
abstract class Connection extends EmbindClassHandle<Connection> {
/**
* Get the filename associated with a connection.
*/
readonly filename: string;
/**
* Make a human-readable name for a connection suitable for error messages.
*/
readonly nick: string;
}
/**
* An input connection.
*/
class Source extends Connection {
/**
* Make a new source from a file.
*
* Make a new source that is attached to the named file. For example:
* ```js
* const source = vips.Source.newFromFile('myfile.jpg');
* ```
* You can pass this source to (for example) [[Image.newFromSource]].
* @param filename The file.
* @return A new source.
*/
static newFromFile(filename: string): Source;
/**
* Make a new source from a memory object.
*
* Make a new source that is attached to the memory object. For example:
* ```js
* const data = image.writeToBuffer('.jpg');
* const source = vips.Source.newFromMemory(data);
* ```
* You can pass this source to (for example) [[Image.newFromSource]].
* @param memory The memory object.
* @return A new source.
*/
static newFromMemory(memory: Blob): Source;
}
/**
* A source that can be attached to callbacks to implement behavior.
*/
class SourceCustom extends Source {
/**
* Attach a read handler.
* @param ptr A pointer to an array of bytes where the read content is stored.
* @param size The maximum number of bytes to be read.
* @return The total number of bytes read into the buffer.
*/
onRead: (ptr: number, size: bigint) => bigint;
/**
* Attach a seek handler.
* Seek handlers are optional. If you do not set one, your source will be
* treated as unseekable and libvips will do extra caching.
* @param offset A byte offset relative to the whence parameter.
* @param size A value indicating the reference point used to obtain the new position.
* @return The new position within the current source.
*/
onSeek: (offset: bigint, whence: number) => bigint;
}
/**
* An output connection.
*/
class Target extends Connection {
/**
* Make a new target to write to a file.
*
* Make a new target that will write to the named file. For example::
* ```js
* const target = vips.Target.newToFile('myfile.jpg');
* ```
* You can pass this target to (for example) [[image.writeToTarget]].
* @param filename Write to this this file.
* @return A new target.
*/
static newToFile(filename: string): Target;
/**
* Make a new target to write to an area of memory.
*
* Make a new target that will write to memory. For example:
* ```js
* const target = vips.Target.newToMemory();
* ```
* You can pass this target to (for example) [[image.writeToTarget]].
*
* After writing to the target, fetch the bytes from the target object with [[getBlob]].
* @return A new target.
*/
static newToMemory(): Target;
/**
* Fetch the typed array of 8-bit unsigned integer values
* from the target object.
*
* @return A typed array of 8-bit unsigned integer values.
*/
getBlob(): Uint8Array;
}
/**
* A target that can be attached to callbacks to implement behavior.
*/
class TargetCustom extends Target {
/**
* Attach a write handler.
* @param ptr A pointer to an array of bytes which will be written to.
* @param length The number of bytes to write.
* @return The number of bytes that were written.
*/
onWrite: (ptr: number, size: bigint) => bigint;
/* libtiff needs to be able to seek and read on targets, unfortunately.
*/
/**
* Attach a read handler.
* @param ptr A pointer to an array of bytes where the read content is stored.
* @param size The maximum number of bytes to be read.
* @return The total number of bytes read from the target.
*/
onRead: (ptr: number, size: bigint) => bigint;
/**
* Attach a seek handler.
* @param offset A byte offset relative to the whence parameter.
* @param size A value indicating the reference point used to obtain the new position.
* @return The new position within the current target.
*/
onSeek: (offset: bigint, whence: number) => bigint;
/**
* Attach an end handler.
* This optional handler is called at the end of write. It should do any
* cleaning up, if necessary.
* @return 0 on success, -1 on error.
*/
onEnd: () => number;
}
/**
* A class to build various interpolators.
* For e.g. nearest, bilinear, and some non-linear.
*/
class Interpolate extends EmbindClassHandle<Interpolate> {
/**
* Look up an interpolator from a nickname and make one.
* @param nickname Nickname for interpolator.
* @return An interpolator.
*/
static newFromName(nickname: string): Interpolate;
}
/**
* An image class.
*/
class Image extends ImageAutoGen {
/**
* Image width in pixels.
*/
readonly width: number;
/**
* Image height in pixels.
*/
readonly height: number;
/**
* Number of bands in image.
*/
readonly bands: number;
/**
* Pixel format in image.
*/
readonly format: string;
/**
* Pixel coding.
*/
readonly coding: string;
/**
* Pixel interpretation.
*/
readonly interpretation: string;
/**
* Horizontal offset of origin.
*/
readonly xoffset: number;
/**
* Vertical offset of origin.
*/
readonly yoffset: number;
/**
* Horizontal resolution in pixels/mm.
*/
readonly xres: number;
/**
* Vertical resolution in pixels/mm.
*/
readonly yres: number;
/**
* Image filename.
*/
readonly filename: string;
//#region Constructor functions
/**
* Creates a new image which, when written to, will create a memory image.
* @return A new image.
*/
static newMemory(): Image;
/**
* Make a new temporary image.
*
* Returns an image backed by a temporary file. When written to with
* [[write]], a temporary file will be created on disc in the
* specified format. When the image is closed, the file will be deleted
* automatically.
*
* The file is created in the temporary directory. This is set with
* the environment variable `TMPDIR`. If this is not set, vips will
* default to `/tmp`.
*
* libvips uses `g_mkstemp()` to make the temporary filename. They
* generally look something like `"vips-12-EJKJFGH.v"`.
* @param format The format for the temp file, defaults to a vips
* format file (`"%s.v"`). The `%s` is substituted by the file path.
* @return A new image.
*/
static newTempFile(format?: string): Image;
/**
* Load an image from a file.
*
* This method can load images in any format supported by libvips. The
* filename can include load options, for example:
* ```js
* const image = vips.Image.newFromFile('fred.jpg[shrink=2]');
* ```
* You can also supply options as keyword arguments, for example:
* ```js
* const image = vips.Image.newFromFile('fred.jpg', {
* shrink: 2
* });
* ```
* The full set of options available depend upon the load operation that
* will be executed. Try something like:
* ```bash
* $ vips jpegload
* ```
* at the command-line to see a summary of the available options for the
* JPEG loader.
*
* Loading is fast: only enough of the image is loaded to be able to fill
* out the header. Pixels will only be decompressed when they are needed.
* @param vipsFilename The file to load the image from, with optional appended arguments.
* @param options Optional options that depend on the load operation.
* @return A new image.
*/
static newFromFile(vipsFilename: string, options?: {
/**
* Force open via memory.
*/
memory?: boolean
/**
* Hint the expected access pattern for the image.
*/
access?: Access | Enum
/**
* The type of error that will cause load to fail. By default,
* loaders are permissive, that is, [[FailOn.none]].
*/
fail_on?: FailOn | Enum
}): Image;
/**
* Wrap an image around a memory array.
*
* Wraps an Image around an area of memory containing a C-style array. For
* example, if the `data` memory array contains four bytes with the
* values 1, 2, 3, 4, you can make a one-band, 2x2 uchar image from
* it like this:
* ```js
* const data = new Uint8Array([1, 2, 3, 4]);
* const image = vips.Image.newFromMemory(data, 2, 2, 1, vips.BandFormat.uchar);
* ```
* The data object will internally be copied from JavaScript to WASM.
*
* This method is useful for efficiently transferring images from WebGL into
* libvips.
*
* See [[writeToMemory]] for the opposite operation.
* Use [[copy]] to set other image attributes.
* @param data A C-style JavaScript array.
* @param width Image width in pixels.
* @param height Image height in pixels.
* @param bands Number of bands.
* @param format Band format.
* @return A new image.
*/
static newFromMemory(data: Blob, width: number, height: number, bands: number, format: BandFormat): Image;
/**
* Wrap an image around a pointer.
*
* This behaves exactly as [[newFromMemory]], but the image is
* loaded from a pointer rather than from a JavaScript array.
* @param ptr A memory address.
* @param size Length of memory area.
* @param width Image width in pixels.
* @param height Image height in pixels.
* @param bands Number of bands.
* @param format Band format.
* @return A new image.
*/
static newFromMemory(ptr: number, size: number, width: number, height: number, bands: number, format: BandFormat): Image;
/**
* Load a formatted image from memory.
*
* This behaves exactly as [[newFromFile]], but the image is
* loaded from the memory object rather than from a file. The
* memory object can be a string or buffer.
* @param data The memory object to load the image from.
* @param strOptions Load options as a string.
* @param options Optional options that depend on the load operation.
* @return A new image.
*/
static newFromBuffer(data: Blob, strOptions?: string, options?: {
/**
* Hint the expected access pattern for the image.
*/
access?: Access | Enum
/**
* The type of error that will cause load to fail. By default,
* loaders are permissive, that is, [[FailOn.none]].
*/
fail_on?: FailOn | Enum
}): Image;
/**
* Load a formatted image from a source.
*
* This behaves exactly as [[newFromFile]], but the image is
* loaded from a source rather than from a file.
* @param source The source to load the image from.
* @param strOptions Load options as a string.
* @param options Optional options that depend on the load operation.
* @return A new image.
*/
static newFromSource(source: Source, strOptions?: string, options?: {
/**
* Hint the expected access pattern for the image.
*/
access?: Access | Enum
/**
* The type of error that will cause load to fail. By default,
* loaders are permissive, that is, [[FailOn.none]].
*/
fail_on?: FailOn | Enum
}): Image;
/**
* Create an image from a 1D array.
*
* A new one-band image with [[BandFormat.double]] pixels is
* created from the array. These images are useful with the libvips
* convolution operator [[conv]].
* @param width Image width.
* @param height Image height.
* @param array Create the image from these values.
* @return A new image.
*/
static newMatrix(width: number, height: number, array?: ArrayConstant): Image;
/**
* Create an image from a 2D array.
*
* A new one-band image with [[BandFormat.double]] pixels is
* created from the array. These images are useful with the libvips
* convolution operator [[conv]].
* @param array Create the image from these values.
* @param scale Default to 1.0. What to divide each pixel by after
* convolution. Useful for integer convolution masks.
* @param offset Default to 0.0. What to subtract from each pixel
* after convolution. Useful for integer convolution masks.
* @return A new image.
*/
static newFromArray(array: ArrayConstant, scale?: number, offset?: number): Image;
/**
* Make a new image from an existing one.
*
* A new image is created which has the same size, format, interpretation
* and resolution as itself, but with every pixel set to `value`.
* @param value The value for the pixels. Use a single number to make a
* one-band image; use an array constant to make a many-band image.
* @return A new image.
*/
newFromImage(value: ArrayConstant): Image;
/**
* Copy an image to memory.
*
* A large area of memory is allocated, the image is rendered to that
* memory area, and a new image is returned which wraps that large memory
* area.
* @return A new image.
*/
copyMemory(): Image;
//#endregion
//#region Writer functions
/**
* Write an image to another image.
*
* This function writes itself to another image. Use something like
* [[newTempFile]] to make an image that can be written to.
* @param other The image to write to.
* @return A new image.
*/
write(other: Image): Image;
/**
* Write an image to a file.
*
* This method can save images in any format supported by libvips. The format
* is selected from the filename suffix. The filename can include embedded
* save options, see [[newFromFile]].
*
* For example:
* ```js
* image.writeToFile('fred.jpg[Q=95]');
* ```
* You can also supply options as keyword arguments, for example:
* ```js
* image.writeToFile('.fred.jpg', {
* Q: 95
* });
* ```
* The full set of options available depend upon the save operation that
* will be executed. Try something like:
* ```bash
* $ vips jpegsave
* ```
* at the command-line to see a summary of the available options for the
* JPEG saver.
* @param vipsFilename The file to save the image to, with optional appended arguments.
* @param options Optional options that depend on the save operation.
*/
writeToFile(vipsFilename: string, options?: {}): void;
/**
* Write an image to a typed array of 8-bit unsigned integer values.
*
* This method can save images in any format supported by libvips. The format
* is selected from the suffix in the format string. This can include
* embedded save options, see [[newFromFile]].
*
* For example:
* ```js
* const data = image.writeToBuffer('.jpg[Q=95]');
* ```
* You can also supply options as keyword arguments, for example:
* ```js
* const data = image.writeToBuffer('.jpg', {
* Q: 85
* });
* ```
* The full set of options available depend upon the load operation that
* will be executed. Try something like:
* ```bash
* $ vips jpegsave_buffer
* ```
* at the command-line to see a summary of the available options for the
* JPEG saver.
* @param formatString The suffix, plus any string-form arguments.
* @param options Optional options that depend on the save operation.
* @return A typed array of 8-bit unsigned integer values.
*/
writeToBuffer(formatString: string, options?: {}): Uint8Array;
/**
* Write an image to a target.
*
* This behaves exactly as [[writeToFile]], but the image is
* written to a target rather than a file.
* @param target Write to this target.
* @param formatString The suffix, plus any string-form arguments.
* @param options Optional options that depend on the save operation.
*/
writeToTarget(target: Target, formatString: string, options?: {}): void;
/**
* Write the image to a large memory array.
*
* A large area of memory is allocated, the image is rendered to that
* memory array, and the array is returned as a typed array.
*
* For example, if you have a 2x2 uchar image containing the bytes 1, 2,
* 3, 4, read left-to-right, top-to-bottom, then:
* ```js
* const array = Uint8Array.of(1, 2, 3, 4);
* const im = vips.Image.newFromMemory(array, 2, 2, 1, 'uchar');
* const buf = im.writeToMemory();
* ```
* will return a four byte typed array containing the values 1, 2, 3, 4.
* @return A typed array of 8-bit unsigned integer values.
*/
writeToMemory(): Uint8Array;
//#endregion
//#region get/set metadata
/**
* Set an integer on an image as metadata.
* @param name The name of the piece of metadata to set the value of.
* @param value The metadata value.
*/
setInt(name: string, value: number): void;
/**
* Set an integer array on an image as metadata.
* @param name The name of the piece of metadata to set the value of.
* @param value The metadata value.
*/
setArrayInt(name: string, value: ArrayConstant): void;
/**
* Set an double array on an image as metadata.
* @param name The name of the piece of metadata to set the value of.
* @param value The metadata value.
*/
setArrayDouble(name: string, value: ArrayConstant): void;
/**
* Set an double on an image as metadata.
* @param name The name of the piece of metadata to set the value of.
* @param value The metadata value.
*/
setDouble(name: string, value: number): void;
/**
* Set an string on an image as metadata.
* @param name The name of the piece of metadata to set the value of.
* @param value The metadata value.
*/
setString(name: string, value: string): void;
/**
* Set an blob on an image as metadata.
* The value will internally be copied from JavaScript to WASM.
* @param name The name of the piece of metadata to set the value of.
* @param value The metadata value.
*/
setBlob(name: string, value: Blob): void;
/**
* Set an blob pointer on an image as metadata.
* @param name The name of the piece of metadata to set the value of.
* @param ptr The metadata value as memory address.
* @param size Length of blob.
*/
setBlob(name: string, ptr: number, size: number): void;
/**
* Get the GType of an item of metadata.
* Fetch the GType of a piece of metadata, or 0 if the named item does not exist.
* @param name The name of the piece of metadata to get the type of.
* @return The GType, or `0` if not found.
*/
getTypeof(name: string): number;
/**
* Get an integer from an image.
* @param name The name of the piece of metadata to get.
* @return The metadata item as an integer.
*/
getInt(name: string): number;
/**
* Get an integer array from an image.
* @param name The name of the piece of metadata to get.
* @return The metadata item as an integer array.
*/
getArrayInt(name: string): number[];
/**
* Get an double array from an image.
* @param name The name of the piece of metadata to get.
* @return The metadata item as an double array.
*/
getArrayDouble(name: string): number[];
/**
* Get an double from an image.
* @param name The name of the piece of metadata to get.
* @return The metadata item as an double.
*/
getDouble(name: string): number;
/**
* Get an string from an image.
* @param name The name of the piece of metadata to get.
* @return The metadata item as an string.
*/
getString(name: string): string;
/**
* Get an blob from an image.
* @param name The name of the piece of metadata to get.
* @return The metadata item as an typed array of 8-bit unsigned integer values.
*/
getBlob(name: string): Uint8Array;
/**
* Get a list of all the metadata fields on an image.
* @return All metadata fields as string vector.
*/
getFields(): Vector<string>;
/**
* Remove an item of metadata.
* @param name The name of the piece of metadata to remove.
* @return `true` if successfully removed.
*/
remove(name: string): string;
//#endregion
//#region Handwritten functions
/**
* Does this image have an alpha channel?
* @return `true` if this image has an alpha channel.
*/
hasAlpha(): boolean;
/**
* Sets the `delete_on_close` flag for the image.
* If this flag is set, when image is finalized, the filename held in
* [[image.filename]] at the time of this call is deleted.
* This function is clearly extremely dangerous, use with great caution.
*/
setDeleteOnClose(flag: boolean): void;
/**
* Search an image for non-edge areas.
* @param options Optional options.
* @return The bounding box of the non-background area.
*/
findTrim(options?: {
/**
* Object threshold.
*/
threshold?: number
/**
* Color for background pixels.
*/
background?: ArrayConstant
}): {
/**
* Output left edge.
*/
left: number
/**
* Output top edge.
*/
top: number
/**
* Output width.
*/
width: number
/**
* Output width.
*/
height: number
};
/**
* Find image profiles.
* @return First non-zero pixel in column/row.
*/
profile(): {
/**
* Distances from top edge.
*/
columns: Image
/**
* Distances from left edge.
*/
rows: Image
};
/**
* Find image projections.
* @return Sums of columns/rows.
*/
project(): {
/**
* Sums of columns.
*/
columns: Image
/**
* Sums of rows.
*/
rows: Image