@napi-rs/image 1.1.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/index.d.ts +40 -46
- package/package.json +17 -14
package/README.md
CHANGED
|
@@ -19,8 +19,8 @@ This library support encode/decode these formats:
|
|
|
19
19
|
| BMP | ✅ | Rgb8, Rgba8, Gray8, GrayA8 |
|
|
20
20
|
| ICO | ✅ | ✅ |
|
|
21
21
|
| TIFF | Baseline(no fax support) + LZW + PackBits | Rgb8, Rgba8, Gray8 |
|
|
22
|
-
| WebP |
|
|
23
|
-
| AVIF |
|
|
22
|
+
| WebP | ✅ | ✅ |
|
|
23
|
+
| AVIF | ✅ | ✅ |
|
|
24
24
|
| PNM | PBM, PGM, PPM, standard PAM | ✅ |
|
|
25
25
|
| DDS | DXT1, DXT3, DXT5 | No |
|
|
26
26
|
| TGA | ✅ | Rgb8, Rgba8, Bgr8, Bgra8, Gray8, GrayA8 |
|
|
@@ -495,7 +495,7 @@ blur(sigma: number): this
|
|
|
495
495
|
|
|
496
496
|
#### `unsharpen`
|
|
497
497
|
|
|
498
|
-
> Performs an unsharpen mask on this image. <br/>
|
|
498
|
+
> Performs an unsharpen mask on this image. <br/> `sigma` is the amount to blur the image by. <br/> `threshold` is a control of how much to sharpen.
|
|
499
499
|
>
|
|
500
500
|
> See <https://en.wikipedia.org/wiki/Unsharp_masking#Digital_unsharp_masking>
|
|
501
501
|
|
|
@@ -513,7 +513,7 @@ filter3x3(kernel: Array<number>): this
|
|
|
513
513
|
|
|
514
514
|
#### `adjustContrast`
|
|
515
515
|
|
|
516
|
-
> Adjust the contrast of this image.<br/>
|
|
516
|
+
> Adjust the contrast of this image.<br/> `contrast` is the amount to adjust the contrast by.<br/>
|
|
517
517
|
> Negative values decrease the contrast and positive values increase the contrast.
|
|
518
518
|
|
|
519
519
|
```ts
|
|
@@ -522,7 +522,7 @@ adjustContrast(contrast: number): this
|
|
|
522
522
|
|
|
523
523
|
#### `brighten`
|
|
524
524
|
|
|
525
|
-
> Brighten the pixels of this image.<br/>
|
|
525
|
+
> Brighten the pixels of this image.<br/> `value` is the amount to brighten each pixel by. <br/>
|
|
526
526
|
> Negative values decrease the brightness and positive values increase it.
|
|
527
527
|
|
|
528
528
|
```ts
|
|
@@ -531,7 +531,7 @@ brighten(brightness: number): this
|
|
|
531
531
|
|
|
532
532
|
#### `huerotate`
|
|
533
533
|
|
|
534
|
-
> Hue rotate the supplied image.<br/>
|
|
534
|
+
> Hue rotate the supplied image.<br/> `value` is the degrees to rotate each pixel by.
|
|
535
535
|
> 0 and 360 do nothing, the rest rotates by the given degree value.
|
|
536
536
|
> just like the css webkit filter hue-rotate(180)
|
|
537
537
|
|
package/index.d.ts
CHANGED
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
export interface AvifConfig {
|
|
7
7
|
/** 0-100 scale, 100 is lossless */
|
|
8
|
-
quality?: number
|
|
8
|
+
quality?: number
|
|
9
9
|
/** 0-100 scale */
|
|
10
|
-
alphaQuality?: number
|
|
10
|
+
alphaQuality?: number
|
|
11
11
|
/** rav1e preset 1 (slow) 10 (fast but crappy), default is 4 */
|
|
12
|
-
speed?: number
|
|
12
|
+
speed?: number
|
|
13
13
|
/** How many threads should be used (0 = match core count) */
|
|
14
|
-
threads?: number
|
|
14
|
+
threads?: number
|
|
15
15
|
/** set to '4:2:0' to use chroma subsampling, default '4:4:4' */
|
|
16
|
-
chromaSubsampling?: ChromaSubsampling
|
|
16
|
+
chromaSubsampling?: ChromaSubsampling
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* https://en.wikipedia.org/wiki/Chroma_subsampling#Types_of_sampling_and_subsampling
|
|
@@ -55,23 +55,19 @@ export const enum ChromaSubsampling {
|
|
|
55
55
|
* What if the chroma subsampling model is 4:0:0?
|
|
56
56
|
* That says to use every pixel of luma data, but that each row has 0 chroma samples applied to it. The resulting image, then, is comprised solely of the luminance data—a greyscale image.
|
|
57
57
|
*/
|
|
58
|
-
Yuv400 = 3
|
|
58
|
+
Yuv400 = 3
|
|
59
59
|
}
|
|
60
60
|
export interface JpegCompressOptions {
|
|
61
61
|
/** Output quality, default is 100 (lossless) */
|
|
62
|
-
quality?: number
|
|
62
|
+
quality?: number
|
|
63
63
|
/**
|
|
64
64
|
* If true, it will use MozJPEG’s scan optimization. Makes progressive image files smaller.
|
|
65
65
|
* Default is `true`
|
|
66
66
|
*/
|
|
67
|
-
optimizeScans?: boolean
|
|
67
|
+
optimizeScans?: boolean
|
|
68
68
|
}
|
|
69
69
|
export function compressJpegSync(input: Buffer, options?: JpegCompressOptions | undefined | null): Buffer
|
|
70
|
-
export function compressJpeg(
|
|
71
|
-
input: Buffer,
|
|
72
|
-
options?: JpegCompressOptions | undefined | null,
|
|
73
|
-
signal?: AbortSignal | undefined | null,
|
|
74
|
-
): Promise<Buffer>
|
|
70
|
+
export function compressJpeg(input: Buffer, options?: JpegCompressOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>
|
|
75
71
|
export const enum CompressionType {
|
|
76
72
|
/** Default compression level */
|
|
77
73
|
Default = 0,
|
|
@@ -82,7 +78,7 @@ export const enum CompressionType {
|
|
|
82
78
|
/** Huffman coding compression */
|
|
83
79
|
Huffman = 3,
|
|
84
80
|
/** Run-length encoding compression */
|
|
85
|
-
Rle = 4
|
|
81
|
+
Rle = 4
|
|
86
82
|
}
|
|
87
83
|
export const enum FilterType {
|
|
88
84
|
/**
|
|
@@ -102,87 +98,79 @@ export const enum FilterType {
|
|
|
102
98
|
* Uses a heuristic to select one of the preceding filters for each
|
|
103
99
|
* scanline rather than one filter for the entire image
|
|
104
100
|
*/
|
|
105
|
-
Adaptive = 5
|
|
101
|
+
Adaptive = 5
|
|
106
102
|
}
|
|
107
103
|
export interface PngEncodeOptions {
|
|
108
104
|
/** Default is `CompressionType::Default` */
|
|
109
|
-
compressionType?: CompressionType
|
|
105
|
+
compressionType?: CompressionType
|
|
110
106
|
/** Default is `FilterType::NoFilter` */
|
|
111
|
-
filterType?: FilterType
|
|
107
|
+
filterType?: FilterType
|
|
112
108
|
}
|
|
113
109
|
export interface PNGLosslessOptions {
|
|
114
110
|
/**
|
|
115
111
|
* Attempt to fix errors when decoding the input file rather than returning an Err.
|
|
116
112
|
* Default: `false`
|
|
117
113
|
*/
|
|
118
|
-
fixErrors?: boolean
|
|
114
|
+
fixErrors?: boolean
|
|
119
115
|
/**
|
|
120
116
|
* Write to output even if there was no improvement in compression.
|
|
121
117
|
* Default: `false`
|
|
122
118
|
*/
|
|
123
|
-
force?: boolean
|
|
119
|
+
force?: boolean
|
|
124
120
|
/** Which filters to try on the file (0-5) */
|
|
125
|
-
filter?: Array<number>
|
|
121
|
+
filter?: Array<number>
|
|
126
122
|
/**
|
|
127
123
|
* Whether to attempt bit depth reduction
|
|
128
124
|
* Default: `true`
|
|
129
125
|
*/
|
|
130
|
-
bitDepthReduction?: boolean
|
|
126
|
+
bitDepthReduction?: boolean
|
|
131
127
|
/**
|
|
132
128
|
* Whether to attempt color type reduction
|
|
133
129
|
* Default: `true`
|
|
134
130
|
*/
|
|
135
|
-
colorTypeReduction?: boolean
|
|
131
|
+
colorTypeReduction?: boolean
|
|
136
132
|
/**
|
|
137
133
|
* Whether to attempt palette reduction
|
|
138
134
|
* Default: `true`
|
|
139
135
|
*/
|
|
140
|
-
paletteReduction?: boolean
|
|
136
|
+
paletteReduction?: boolean
|
|
141
137
|
/**
|
|
142
138
|
* Whether to attempt grayscale reduction
|
|
143
139
|
* Default: `true`
|
|
144
140
|
*/
|
|
145
|
-
grayscaleReduction?: boolean
|
|
141
|
+
grayscaleReduction?: boolean
|
|
146
142
|
/**
|
|
147
143
|
* Whether to perform IDAT recoding
|
|
148
144
|
* If any type of reduction is performed, IDAT recoding will be performed regardless of this setting
|
|
149
145
|
* Default: `true`
|
|
150
146
|
*/
|
|
151
|
-
idatRecoding?: boolean
|
|
147
|
+
idatRecoding?: boolean
|
|
152
148
|
/** Whether to remove ***All non-critical headers*** on PNG */
|
|
153
|
-
strip?: boolean
|
|
149
|
+
strip?: boolean
|
|
154
150
|
/** Whether to use heuristics to pick the best filter and compression */
|
|
155
|
-
useHeuristics?: boolean
|
|
151
|
+
useHeuristics?: boolean
|
|
156
152
|
}
|
|
157
153
|
export function losslessCompressPngSync(input: Buffer, options?: PNGLosslessOptions | undefined | null): Buffer
|
|
158
|
-
export function losslessCompressPng(
|
|
159
|
-
input: Buffer,
|
|
160
|
-
options?: PNGLosslessOptions | undefined | null,
|
|
161
|
-
signal?: AbortSignal | undefined | null,
|
|
162
|
-
): Promise<Buffer>
|
|
154
|
+
export function losslessCompressPng(input: Buffer, options?: PNGLosslessOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>
|
|
163
155
|
export interface PngQuantOptions {
|
|
164
156
|
/** default is 70 */
|
|
165
|
-
minQuality?: number
|
|
157
|
+
minQuality?: number
|
|
166
158
|
/** default is 99 */
|
|
167
|
-
maxQuality?: number
|
|
159
|
+
maxQuality?: number
|
|
168
160
|
/**
|
|
169
161
|
* 1- 10
|
|
170
162
|
* Faster speeds generate images of lower quality, but may be useful for real-time generation of images.
|
|
171
163
|
* default: 5
|
|
172
164
|
*/
|
|
173
|
-
speed?: number
|
|
165
|
+
speed?: number
|
|
174
166
|
/**
|
|
175
167
|
* Number of least significant bits to ignore.
|
|
176
168
|
* Useful for generating palettes for VGA, 15-bit textures, or other retro platforms.
|
|
177
169
|
*/
|
|
178
|
-
posterization?: number
|
|
170
|
+
posterization?: number
|
|
179
171
|
}
|
|
180
172
|
export function pngQuantizeSync(input: Buffer, options?: PngQuantOptions | undefined | null): Buffer
|
|
181
|
-
export function pngQuantize(
|
|
182
|
-
input: Buffer,
|
|
183
|
-
options?: PngQuantOptions | undefined | null,
|
|
184
|
-
signal?: AbortSignal | undefined | null,
|
|
185
|
-
): Promise<Buffer>
|
|
173
|
+
export function pngQuantize(input: Buffer, options?: PngQuantOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>
|
|
186
174
|
export const enum Orientation {
|
|
187
175
|
/** Normal */
|
|
188
176
|
Horizontal = 1,
|
|
@@ -192,7 +180,7 @@ export const enum Orientation {
|
|
|
192
180
|
MirrorHorizontalAndRotate270Cw = 5,
|
|
193
181
|
Rotate90Cw = 6,
|
|
194
182
|
MirrorHorizontalAndRotate90Cw = 7,
|
|
195
|
-
Rotate270Cw = 8
|
|
183
|
+
Rotate270Cw = 8
|
|
196
184
|
}
|
|
197
185
|
/**
|
|
198
186
|
* Available Sampling Filters.
|
|
@@ -272,7 +260,7 @@ export const enum ResizeFilterType {
|
|
|
272
260
|
/** Gaussian Filter */
|
|
273
261
|
Gaussian = 3,
|
|
274
262
|
/** Lanczos with window 3 */
|
|
275
|
-
Lanczos3 = 4
|
|
263
|
+
Lanczos3 = 4
|
|
276
264
|
}
|
|
277
265
|
export const enum JsColorType {
|
|
278
266
|
/** Pixel is 8-bit luminance */
|
|
@@ -294,13 +282,13 @@ export const enum JsColorType {
|
|
|
294
282
|
/** Pixel is 32-bit float RGB */
|
|
295
283
|
Rgb32F = 8,
|
|
296
284
|
/** Pixel is 32-bit float RGBA */
|
|
297
|
-
Rgba32F = 9
|
|
285
|
+
Rgba32F = 9
|
|
298
286
|
}
|
|
299
287
|
export interface Metadata {
|
|
300
288
|
width: number
|
|
301
289
|
height: number
|
|
302
|
-
exif?: Record<string, string>
|
|
303
|
-
orientation?: number
|
|
290
|
+
exif?: Record<string, string>
|
|
291
|
+
orientation?: number
|
|
304
292
|
format: string
|
|
305
293
|
colorType: JsColorType
|
|
306
294
|
}
|
|
@@ -362,6 +350,12 @@ export class Transformer {
|
|
|
362
350
|
* just like the css webkit filter hue-rotate(180)
|
|
363
351
|
*/
|
|
364
352
|
huerotate(hue: number): this
|
|
353
|
+
/** Crop a cut-out of this image delimited by the bounding rectangle. */
|
|
354
|
+
crop(x: number, y: number, width: number, height: number): this
|
|
355
|
+
/** Return this image's pixels as a native endian byte slice. */
|
|
356
|
+
rawPixels(signal?: AbortSignal | undefined | null): Promise<Buffer>
|
|
357
|
+
/** Return this image's pixels as a native endian byte slice. */
|
|
358
|
+
rawPixelsSync(): Buffer
|
|
365
359
|
/**
|
|
366
360
|
* The quality factor `quality_factor` ranges from 0 to 100 and controls the loss and quality during compression.
|
|
367
361
|
* The value 0 corresponds to low quality and small output sizes, whereas 100 is the highest quality and largest output size.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@napi-rs/image",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"description": "Image processing library",
|
|
@@ -60,19 +60,22 @@
|
|
|
60
60
|
"version": "napi version"
|
|
61
61
|
},
|
|
62
62
|
"repository": "git@github.com:Brooooooklyn/Image.git",
|
|
63
|
-
"
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@napi-rs/cli": "^2.9.0"
|
|
65
|
+
},
|
|
66
|
+
"gitHead": "e2e01fdd67e087b1468a933bbe5ea15d40a41315",
|
|
64
67
|
"optionalDependencies": {
|
|
65
|
-
"@napi-rs/image-win32-x64-msvc": "1.
|
|
66
|
-
"@napi-rs/image-darwin-x64": "1.
|
|
67
|
-
"@napi-rs/image-linux-x64-gnu": "1.
|
|
68
|
-
"@napi-rs/image-darwin-arm64": "1.
|
|
69
|
-
"@napi-rs/image-android-arm64": "1.
|
|
70
|
-
"@napi-rs/image-linux-arm64-gnu": "1.
|
|
71
|
-
"@napi-rs/image-linux-arm64-musl": "1.
|
|
72
|
-
"@napi-rs/image-linux-arm-gnueabihf": "1.
|
|
73
|
-
"@napi-rs/image-linux-x64-musl": "1.
|
|
74
|
-
"@napi-rs/image-freebsd-x64": "1.
|
|
75
|
-
"@napi-rs/image-win32-ia32-msvc": "1.
|
|
76
|
-
"@napi-rs/image-android-arm-eabi": "1.
|
|
68
|
+
"@napi-rs/image-win32-x64-msvc": "1.3.0",
|
|
69
|
+
"@napi-rs/image-darwin-x64": "1.3.0",
|
|
70
|
+
"@napi-rs/image-linux-x64-gnu": "1.3.0",
|
|
71
|
+
"@napi-rs/image-darwin-arm64": "1.3.0",
|
|
72
|
+
"@napi-rs/image-android-arm64": "1.3.0",
|
|
73
|
+
"@napi-rs/image-linux-arm64-gnu": "1.3.0",
|
|
74
|
+
"@napi-rs/image-linux-arm64-musl": "1.3.0",
|
|
75
|
+
"@napi-rs/image-linux-arm-gnueabihf": "1.3.0",
|
|
76
|
+
"@napi-rs/image-linux-x64-musl": "1.3.0",
|
|
77
|
+
"@napi-rs/image-freebsd-x64": "1.3.0",
|
|
78
|
+
"@napi-rs/image-win32-ia32-msvc": "1.3.0",
|
|
79
|
+
"@napi-rs/image-android-arm-eabi": "1.3.0"
|
|
77
80
|
}
|
|
78
81
|
}
|