@napi-rs/image 1.0.0 → 1.1.2

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/index.d.ts CHANGED
@@ -3,11 +3,112 @@
3
3
 
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
- export class ExternalObject<T> {
7
- readonly '': {
8
- readonly '': unique symbol
9
- [K: symbol]: T
10
- }
6
+ export interface AvifConfig {
7
+ /** 0-100 scale, 100 is lossless */
8
+ quality?: number | undefined | null
9
+ /** 0-100 scale */
10
+ alphaQuality?: number | undefined | null
11
+ /** rav1e preset 1 (slow) 10 (fast but crappy), default is 4 */
12
+ speed?: number | undefined | null
13
+ /** How many threads should be used (0 = match core count) */
14
+ threads?: number | undefined | null
15
+ /** set to '4:2:0' to use chroma subsampling, default '4:4:4' */
16
+ chromaSubsampling?: ChromaSubsampling | undefined | null
17
+ }
18
+ /**
19
+ * https://en.wikipedia.org/wiki/Chroma_subsampling#Types_of_sampling_and_subsampling
20
+ * https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Video_concepts
21
+ */
22
+ export const enum ChromaSubsampling {
23
+ /**
24
+ * Each of the three Y'CbCr components has the same sample rate, thus there is no chroma subsampling. This scheme is sometimes used in high-end film scanners and cinematic post-production.
25
+ * Note that "4:4:4" may instead be wrongly referring to R'G'B' color space, which implicitly also does not have any chroma subsampling (except in JPEG R'G'B' can be subsampled).
26
+ * Formats such as HDCAM SR can record 4:4:4 R'G'B' over dual-link HD-SDI.
27
+ */
28
+ Yuv444 = 0,
29
+ /**
30
+ * The two chroma components are sampled at half the horizontal sample rate of luma: the horizontal chroma resolution is halved. This reduces the bandwidth of an uncompressed video signal by one-third.
31
+ * Many high-end digital video formats and interfaces use this scheme:
32
+ * - [AVC-Intra 100](https://en.wikipedia.org/wiki/AVC-Intra)
33
+ * - [Digital Betacam](https://en.wikipedia.org/wiki/Betacam#Digital_Betacam)
34
+ * - [Betacam SX](https://en.wikipedia.org/wiki/Betacam#Betacam_SX)
35
+ * - [DVCPRO50](https://en.wikipedia.org/wiki/DV#DVCPRO) and [DVCPRO HD](https://en.wikipedia.org/wiki/DV#DVCPRO_HD)
36
+ * - [Digital-S](https://en.wikipedia.org/wiki/Digital-S)
37
+ * - [CCIR 601](https://en.wikipedia.org/wiki/Rec._601) / [Serial Digital Interface](https://en.wikipedia.org/wiki/Serial_digital_interface) / [D1](https://en.wikipedia.org/wiki/D-1_(Sony))
38
+ * - [ProRes (HQ, 422, LT, and Proxy)](https://en.wikipedia.org/wiki/Apple_ProRes)
39
+ * - [XDCAM HD422](https://en.wikipedia.org/wiki/XDCAM)
40
+ * - [Canon MXF HD422](https://en.wikipedia.org/wiki/Canon_XF-300)
41
+ */
42
+ Yuv422 = 1,
43
+ /**
44
+ * n 4:2:0, the horizontal sampling is doubled compared to 4:1:1,
45
+ * but as the **Cb** and **Cr** channels are only sampled on each alternate line in this scheme, the vertical resolution is halved.
46
+ * The data rate is thus the same.
47
+ * This fits reasonably well with the PAL color encoding system, since this has only half the vertical chrominance resolution of [NTSC](https://en.wikipedia.org/wiki/NTSC).
48
+ * It would also fit extremely well with the [SECAM](https://en.wikipedia.org/wiki/SECAM) color encoding system,
49
+ * since like that format, 4:2:0 only stores and transmits one color channel per line (the other channel being recovered from the previous line).
50
+ * However, little equipment has actually been produced that outputs a SECAM analogue video signal.
51
+ * In general, SECAM territories either have to use a PAL-capable display or a [transcoder](https://en.wikipedia.org/wiki/Transcoding) to convert the PAL signal to SECAM for display.
52
+ */
53
+ Yuv420 = 2,
54
+ /**
55
+ * What if the chroma subsampling model is 4:0:0?
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
+ */
58
+ Yuv400 = 3,
59
+ }
60
+ export interface JpegCompressOptions {
61
+ /** Output quality, default is 100 (lossless) */
62
+ quality?: number | undefined | null
63
+ /**
64
+ * If true, it will use MozJPEG’s scan optimization. Makes progressive image files smaller.
65
+ * Default is `true`
66
+ */
67
+ optimizeScans?: boolean | undefined | null
68
+ }
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>
75
+ export const enum CompressionType {
76
+ /** Default compression level */
77
+ Default = 0,
78
+ /** Fast, minimal compression */
79
+ Fast = 1,
80
+ /** High compression level */
81
+ Best = 2,
82
+ /** Huffman coding compression */
83
+ Huffman = 3,
84
+ /** Run-length encoding compression */
85
+ Rle = 4,
86
+ }
87
+ export const enum FilterType {
88
+ /**
89
+ * No processing done, best used for low bit depth greyscale or data with a
90
+ * low color count
91
+ */
92
+ NoFilter = 0,
93
+ /** Filters based on previous pixel in the same scanline */
94
+ Sub = 1,
95
+ /** Filters based on the scanline above */
96
+ Up = 2,
97
+ /** Filters based on the average of left and right neighbor pixels */
98
+ Avg = 3,
99
+ /** Algorithm that takes into account the left, upper left, and above pixels */
100
+ Paeth = 4,
101
+ /**
102
+ * Uses a heuristic to select one of the preceding filters for each
103
+ * scanline rather than one filter for the entire image
104
+ */
105
+ Adaptive = 5,
106
+ }
107
+ export interface PngEncodeOptions {
108
+ /** Default is `CompressionType::Default` */
109
+ compressionType?: CompressionType | undefined | null
110
+ /** Default is `FilterType::NoFilter` */
111
+ filterType?: FilterType | undefined | null
11
112
  }
12
113
  export interface PNGLosslessOptions {
13
114
  /**
@@ -53,14 +154,246 @@ export interface PNGLosslessOptions {
53
154
  /** Whether to use heuristics to pick the best filter and compression */
54
155
  useHeuristics?: boolean | undefined | null
55
156
  }
56
- export function losslessCompressPng(input: Buffer, options?: PNGLosslessOptions | undefined | null): Buffer
57
- export interface JpegCompressOptions {
58
- /** Output quality, default is 100 (lossless) */
59
- quality?: number | undefined | null
157
+ 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>
163
+ export interface PngQuantOptions {
164
+ /** default is 70 */
165
+ minQuality?: number | undefined | null
166
+ /** default is 99 */
167
+ maxQuality?: number | undefined | null
60
168
  /**
61
- * If true, it will use MozJPEG’s scan optimization. Makes progressive image files smaller.
62
- * Default is `true`
169
+ * 1- 10
170
+ * Faster speeds generate images of lower quality, but may be useful for real-time generation of images.
171
+ * default: 5
63
172
  */
64
- optimizeScans?: boolean | undefined | null
173
+ speed?: number | undefined | null
174
+ /**
175
+ * Number of least significant bits to ignore.
176
+ * Useful for generating palettes for VGA, 15-bit textures, or other retro platforms.
177
+ */
178
+ posterization?: number | undefined | null
179
+ }
180
+ 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>
186
+ export const enum Orientation {
187
+ /** Normal */
188
+ Horizontal = 1,
189
+ MirrorHorizontal = 2,
190
+ Rotate180 = 3,
191
+ MirrorVertical = 4,
192
+ MirrorHorizontalAndRotate270Cw = 5,
193
+ Rotate90Cw = 6,
194
+ MirrorHorizontalAndRotate90Cw = 7,
195
+ Rotate270Cw = 8,
196
+ }
197
+ /**
198
+ * Available Sampling Filters.
199
+ *
200
+ * ## Examples
201
+ *
202
+ * To test the different sampling filters on a real example, you can find two
203
+ * examples called
204
+ * [`scaledown`](https://github.com/image-rs/image/tree/master/examples/scaledown)
205
+ * and
206
+ * [`scaleup`](https://github.com/image-rs/image/tree/master/examples/scaleup)
207
+ * in the `examples` directory of the crate source code.
208
+ *
209
+ * Here is a 3.58 MiB
210
+ * [test image](https://github.com/image-rs/image/blob/master/examples/scaledown/test.jpg)
211
+ * that has been scaled down to 300x225 px:
212
+ *
213
+ * <!-- NOTE: To test new test images locally, replace the GitHub path with `../../../docs/` -->
214
+ * <div style="display: flex; flex-wrap: wrap; align-items: flex-start;">
215
+ * <div style="margin: 0 8px 8px 0;">
216
+ * <img src="https://raw.githubusercontent.com/image-rs/image/master/examples/scaledown/scaledown-test-near.png" title="Nearest"><br>
217
+ * Nearest Neighbor
218
+ * </div>
219
+ * <div style="margin: 0 8px 8px 0;">
220
+ * <img src="https://raw.githubusercontent.com/image-rs/image/master/examples/scaledown/scaledown-test-tri.png" title="Triangle"><br>
221
+ * Linear: Triangle
222
+ * </div>
223
+ * <div style="margin: 0 8px 8px 0;">
224
+ * <img src="https://raw.githubusercontent.com/image-rs/image/master/examples/scaledown/scaledown-test-cmr.png" title="CatmullRom"><br>
225
+ * Cubic: Catmull-Rom
226
+ * </div>
227
+ * <div style="margin: 0 8px 8px 0;">
228
+ * <img src="https://raw.githubusercontent.com/image-rs/image/master/examples/scaledown/scaledown-test-gauss.png" title="Gaussian"><br>
229
+ * Gaussian
230
+ * </div>
231
+ * <div style="margin: 0 8px 8px 0;">
232
+ * <img src="https://raw.githubusercontent.com/image-rs/image/master/examples/scaledown/scaledown-test-lcz2.png" title="Lanczos3"><br>
233
+ * Lanczos with window 3
234
+ * </div>
235
+ * </div>
236
+ *
237
+ * ## Speed
238
+ *
239
+ * Time required to create each of the examples above, tested on an Intel
240
+ * i7-4770 CPU with Rust 1.37 in release mode:
241
+ *
242
+ * <table style="width: auto;">
243
+ * <tr>
244
+ * <th>Nearest</th>
245
+ * <td>31 ms</td>
246
+ * </tr>
247
+ * <tr>
248
+ * <th>Triangle</th>
249
+ * <td>414 ms</td>
250
+ * </tr>
251
+ * <tr>
252
+ * <th>CatmullRom</th>
253
+ * <td>817 ms</td>
254
+ * </tr>
255
+ * <tr>
256
+ * <th>Gaussian</th>
257
+ * <td>1180 ms</td>
258
+ * </tr>
259
+ * <tr>
260
+ * <th>Lanczos3</th>
261
+ * <td>1170 ms</td>
262
+ * </tr>
263
+ * </table>
264
+ */
265
+ export const enum ResizeFilterType {
266
+ /** Nearest Neighbor */
267
+ Nearest = 0,
268
+ /** Linear Filter */
269
+ Triangle = 1,
270
+ /** Cubic Filter */
271
+ CatmullRom = 2,
272
+ /** Gaussian Filter */
273
+ Gaussian = 3,
274
+ /** Lanczos with window 3 */
275
+ Lanczos3 = 4,
276
+ }
277
+ export const enum JsColorType {
278
+ /** Pixel is 8-bit luminance */
279
+ L8 = 0,
280
+ /** Pixel is 8-bit luminance with an alpha channel */
281
+ La8 = 1,
282
+ /** Pixel contains 8-bit R, G and B channels */
283
+ Rgb8 = 2,
284
+ /** Pixel is 8-bit RGB with an alpha channel */
285
+ Rgba8 = 3,
286
+ /** Pixel is 16-bit luminance */
287
+ L16 = 4,
288
+ /** Pixel is 16-bit luminance with an alpha channel */
289
+ La16 = 5,
290
+ /** Pixel is 16-bit RGB */
291
+ Rgb16 = 6,
292
+ /** Pixel is 16-bit RGBA */
293
+ Rgba16 = 7,
294
+ /** Pixel is 32-bit float RGB */
295
+ Rgb32F = 8,
296
+ /** Pixel is 32-bit float RGBA */
297
+ Rgba32F = 9,
298
+ }
299
+ export interface Metadata {
300
+ width: number
301
+ height: number
302
+ exif?: Record<string, string> | undefined | null
303
+ orientation?: number | undefined | null
304
+ format: string
305
+ colorType: JsColorType
306
+ }
307
+ export class Transformer {
308
+ constructor(input: Buffer)
309
+ static fromRgbaPixels(input: Buffer | Uint8ClampedArray, width: number, height: number): Transformer
310
+ metadata(withExif?: boolean | undefined | null, signal?: AbortSignal | undefined | null): Promise<Metadata>
311
+ /**
312
+ * Rotate with exif orientation
313
+ * If the orientation param is not null,
314
+ * the new orientation value will override the exif orientation value
315
+ */
316
+ rotate(orientation?: Orientation | undefined | null): this
317
+ /**
318
+ * Return a grayscale version of this image.
319
+ * Returns `Luma` images in most cases. However, for `f32` images,
320
+ * this will return a greyscale `Rgb/Rgba` image instead.
321
+ */
322
+ grayscale(): this
323
+ /** Invert the colors of this image. */
324
+ invert(): this
325
+ /**
326
+ * Resize this image using the specified filter algorithm.
327
+ * The image is scaled to the maximum possible size that fits
328
+ * within the bounds specified by `width` and `height`.
329
+ */
330
+ resize(width: number, height?: number | undefined | null, filterType?: ResizeFilterType | undefined | null): this
331
+ /**
332
+ * Performs a Gaussian blur on this image.
333
+ * `sigma` is a measure of how much to blur by.
334
+ */
335
+ blur(sigma: number): this
336
+ /**
337
+ * Performs an unsharpen mask on this image.
338
+ * `sigma` is the amount to blur the image by.
339
+ * `threshold` is a control of how much to sharpen.
340
+ *
341
+ * See <https://en.wikipedia.org/wiki/Unsharp_masking#Digital_unsharp_masking>
342
+ */
343
+ unsharpen(sigma: number, threshold: number): this
344
+ /** Filters this image with the specified 3x3 kernel. */
345
+ filter3x3(kernel: Array<number>): this
346
+ /**
347
+ * Adjust the contrast of this image.
348
+ * `contrast` is the amount to adjust the contrast by.
349
+ * Negative values decrease the contrast and positive values increase the contrast.
350
+ */
351
+ adjustContrast(contrast: number): this
352
+ /**
353
+ * Brighten the pixels of this image.
354
+ * `value` is the amount to brighten each pixel by.
355
+ * Negative values decrease the brightness and positive values increase it.
356
+ */
357
+ brighten(brightness: number): this
358
+ /**
359
+ * Hue rotate the supplied image.
360
+ * `value` is the degrees to rotate each pixel by.
361
+ * 0 and 360 do nothing, the rest rotates by the given degree value.
362
+ * just like the css webkit filter hue-rotate(180)
363
+ */
364
+ huerotate(hue: number): this
365
+ /**
366
+ * The quality factor `quality_factor` ranges from 0 to 100 and controls the loss and quality during compression.
367
+ * The value 0 corresponds to low quality and small output sizes, whereas 100 is the highest quality and largest output size.
368
+ * https://developers.google.com/speed/webp/docs/api#simple_encoding_api
369
+ */
370
+ webp(qualityFactor?: number | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>
371
+ /**
372
+ * The quality factor `quality_factor` ranges from 0 to 100 and controls the loss and quality during compression.
373
+ * The value 0 corresponds to low quality and small output sizes, whereas 100 is the highest quality and largest output size.
374
+ * https://developers.google.com/speed/webp/docs/api#simple_encoding_api
375
+ */
376
+ webpSync(qualityFactor?: number | undefined | null): Buffer
377
+ webpLossless(signal?: AbortSignal | undefined | null): Promise<Buffer>
378
+ webpLosslessSync(): Buffer
379
+ avif(options?: AvifConfig | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>
380
+ avifSync(options?: AvifConfig | undefined | null): Buffer
381
+ png(options?: PngEncodeOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>
382
+ pngSync(options?: PngEncodeOptions | undefined | null): Buffer
383
+ /** default `quality` is 90 */
384
+ jpeg(quality?: number | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>
385
+ /** default `quality` is 90 */
386
+ jpegSync(quality?: number | undefined | null): Buffer
387
+ bmp(signal?: AbortSignal | undefined | null): Promise<Buffer>
388
+ bmpSync(): Buffer
389
+ ico(signal?: AbortSignal | undefined | null): Promise<Buffer>
390
+ icoSync(): Buffer
391
+ tiff(signal?: AbortSignal | undefined | null): Promise<Buffer>
392
+ tiffSync(): Buffer
393
+ pnm(signal?: AbortSignal | undefined | null): Promise<Buffer>
394
+ pnmSync(): Buffer
395
+ tga(signal?: AbortSignal | undefined | null): Promise<Buffer>
396
+ tgaSync(): Buffer
397
+ farbfeld(signal?: AbortSignal | undefined | null): Promise<Buffer>
398
+ farbfeldSync(): Buffer
65
399
  }
66
- export function compressJpeg(input: Buffer, options?: JpegCompressOptions | undefined | null): Buffer
package/index.js CHANGED
@@ -13,34 +13,51 @@ function isMusl() {
13
13
  try {
14
14
  return readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
15
15
  } catch (e) {
16
- return false
16
+ return true
17
17
  }
18
18
  } else {
19
19
  const { glibcVersionRuntime } = process.report.getReport().header
20
- return !Boolean(glibcVersionRuntime)
20
+ return !glibcVersionRuntime
21
21
  }
22
22
  }
23
23
 
24
24
  switch (platform) {
25
25
  case 'android':
26
- if (arch !== 'arm64') {
27
- throw new Error(`Unsupported architecture on Android ${arch}`)
28
- }
29
- localFileExisted = existsSync(join(__dirname, 'image.android-arm64.node'))
30
- try {
31
- if (localFileExisted) {
32
- nativeBinding = require('./image.android-arm64.node')
33
- } else {
34
- nativeBinding = require('@napi-rs/image-android-arm64')
35
- }
36
- } catch (e) {
37
- loadError = e
26
+ switch (arch) {
27
+ case 'arm64':
28
+ localFileExisted = existsSync(join(__dirname, 'image.android-arm64.node'))
29
+ try {
30
+ if (localFileExisted) {
31
+ nativeBinding = require('./image.android-arm64.node')
32
+ } else {
33
+ nativeBinding = require('@napi-rs/image-android-arm64')
34
+ }
35
+ } catch (e) {
36
+ loadError = e
37
+ }
38
+ break
39
+ case 'arm':
40
+ localFileExisted = existsSync(join(__dirname, 'image.android-arm-eabi.node'))
41
+ try {
42
+ if (localFileExisted) {
43
+ nativeBinding = require('./image.android-arm-eabi.node')
44
+ } else {
45
+ nativeBinding = require('@napi-rs/image-android-arm-eabi')
46
+ }
47
+ } catch (e) {
48
+ loadError = e
49
+ }
50
+ break
51
+ default:
52
+ throw new Error(`Unsupported architecture on Android ${arch}`)
38
53
  }
39
54
  break
40
55
  case 'win32':
41
56
  switch (arch) {
42
57
  case 'x64':
43
- localFileExisted = existsSync(join(__dirname, 'image.win32-x64-msvc.node'))
58
+ localFileExisted = existsSync(
59
+ join(__dirname, 'image.win32-x64-msvc.node')
60
+ )
44
61
  try {
45
62
  if (localFileExisted) {
46
63
  nativeBinding = require('./image.win32-x64-msvc.node')
@@ -52,7 +69,9 @@ switch (platform) {
52
69
  }
53
70
  break
54
71
  case 'ia32':
55
- localFileExisted = existsSync(join(__dirname, 'image.win32-ia32-msvc.node'))
72
+ localFileExisted = existsSync(
73
+ join(__dirname, 'image.win32-ia32-msvc.node')
74
+ )
56
75
  try {
57
76
  if (localFileExisted) {
58
77
  nativeBinding = require('./image.win32-ia32-msvc.node')
@@ -64,7 +83,9 @@ switch (platform) {
64
83
  }
65
84
  break
66
85
  case 'arm64':
67
- localFileExisted = existsSync(join(__dirname, 'image.win32-arm64-msvc.node'))
86
+ localFileExisted = existsSync(
87
+ join(__dirname, 'image.win32-arm64-msvc.node')
88
+ )
68
89
  try {
69
90
  if (localFileExisted) {
70
91
  nativeBinding = require('./image.win32-arm64-msvc.node')
@@ -94,7 +115,9 @@ switch (platform) {
94
115
  }
95
116
  break
96
117
  case 'arm64':
97
- localFileExisted = existsSync(join(__dirname, 'image.darwin-arm64.node'))
118
+ localFileExisted = existsSync(
119
+ join(__dirname, 'image.darwin-arm64.node')
120
+ )
98
121
  try {
99
122
  if (localFileExisted) {
100
123
  nativeBinding = require('./image.darwin-arm64.node')
@@ -128,7 +151,9 @@ switch (platform) {
128
151
  switch (arch) {
129
152
  case 'x64':
130
153
  if (isMusl()) {
131
- localFileExisted = existsSync(join(__dirname, 'image.linux-x64-musl.node'))
154
+ localFileExisted = existsSync(
155
+ join(__dirname, 'image.linux-x64-musl.node')
156
+ )
132
157
  try {
133
158
  if (localFileExisted) {
134
159
  nativeBinding = require('./image.linux-x64-musl.node')
@@ -139,7 +164,9 @@ switch (platform) {
139
164
  loadError = e
140
165
  }
141
166
  } else {
142
- localFileExisted = existsSync(join(__dirname, 'image.linux-x64-gnu.node'))
167
+ localFileExisted = existsSync(
168
+ join(__dirname, 'image.linux-x64-gnu.node')
169
+ )
143
170
  try {
144
171
  if (localFileExisted) {
145
172
  nativeBinding = require('./image.linux-x64-gnu.node')
@@ -153,7 +180,9 @@ switch (platform) {
153
180
  break
154
181
  case 'arm64':
155
182
  if (isMusl()) {
156
- localFileExisted = existsSync(join(__dirname, 'image.linux-arm64-musl.node'))
183
+ localFileExisted = existsSync(
184
+ join(__dirname, 'image.linux-arm64-musl.node')
185
+ )
157
186
  try {
158
187
  if (localFileExisted) {
159
188
  nativeBinding = require('./image.linux-arm64-musl.node')
@@ -164,7 +193,9 @@ switch (platform) {
164
193
  loadError = e
165
194
  }
166
195
  } else {
167
- localFileExisted = existsSync(join(__dirname, 'image.linux-arm64-gnu.node'))
196
+ localFileExisted = existsSync(
197
+ join(__dirname, 'image.linux-arm64-gnu.node')
198
+ )
168
199
  try {
169
200
  if (localFileExisted) {
170
201
  nativeBinding = require('./image.linux-arm64-gnu.node')
@@ -177,7 +208,9 @@ switch (platform) {
177
208
  }
178
209
  break
179
210
  case 'arm':
180
- localFileExisted = existsSync(join(__dirname, 'image.linux-arm-gnueabihf.node'))
211
+ localFileExisted = existsSync(
212
+ join(__dirname, 'image.linux-arm-gnueabihf.node')
213
+ )
181
214
  try {
182
215
  if (localFileExisted) {
183
216
  nativeBinding = require('./image.linux-arm-gnueabihf.node')
@@ -203,7 +236,18 @@ if (!nativeBinding) {
203
236
  throw new Error(`Failed to load native binding`)
204
237
  }
205
238
 
206
- const { losslessCompressPng, compressJpeg } = nativeBinding
239
+ const { ChromaSubsampling, compressJpegSync, compressJpeg, CompressionType, FilterType, losslessCompressPngSync, losslessCompressPng, pngQuantizeSync, pngQuantize, Orientation, ResizeFilterType, JsColorType, Transformer } = nativeBinding
207
240
 
208
- module.exports.losslessCompressPng = losslessCompressPng
241
+ module.exports.ChromaSubsampling = ChromaSubsampling
242
+ module.exports.compressJpegSync = compressJpegSync
209
243
  module.exports.compressJpeg = compressJpeg
244
+ module.exports.CompressionType = CompressionType
245
+ module.exports.FilterType = FilterType
246
+ module.exports.losslessCompressPngSync = losslessCompressPngSync
247
+ module.exports.losslessCompressPng = losslessCompressPng
248
+ module.exports.pngQuantizeSync = pngQuantizeSync
249
+ module.exports.pngQuantize = pngQuantize
250
+ module.exports.Orientation = Orientation
251
+ module.exports.ResizeFilterType = ResizeFilterType
252
+ module.exports.JsColorType = JsColorType
253
+ module.exports.Transformer = Transformer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@napi-rs/image",
3
- "version": "1.0.0",
3
+ "version": "1.1.2",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "description": "Image processing library",
@@ -17,6 +17,10 @@
17
17
  "jpg",
18
18
  "png"
19
19
  ],
20
+ "files": [
21
+ "index.js",
22
+ "index.d.ts"
23
+ ],
20
24
  "publishConfig": {
21
25
  "registry": "https://registry.npmjs.org/",
22
26
  "access": "public"
@@ -38,22 +42,6 @@
38
42
  }
39
43
  },
40
44
  "license": "MIT",
41
- "devDependencies": {
42
- "@napi-rs/cli": "^2.2.1",
43
- "@types/node": "^17.0.8",
44
- "ava": "^4.0.1",
45
- "npm-run-all": "^4.1.5",
46
- "prettier": "^2.5.1"
47
- },
48
- "ava": {
49
- "extensions": [
50
- "mjs"
51
- ],
52
- "timeout": "3m",
53
- "environmentVariables": {
54
- "NODE_ENV": "ava"
55
- }
56
- },
57
45
  "engines": {
58
46
  "node": ">= 10"
59
47
  },
@@ -62,36 +50,32 @@
62
50
  "url": "https://github.com/sponsors/Brooooooklyn"
63
51
  },
64
52
  "scripts": {
65
- "artifacts": "napi artifacts",
53
+ "artifacts": "napi artifacts -d ../../artifacts",
66
54
  "build": "napi build --platform --release",
67
55
  "build:debug": "napi build --platform",
68
56
  "format": "run-p format:prettier format:rs",
69
57
  "format:prettier": "prettier --config ./package.json -w .",
70
58
  "format:rs": "cargo fmt --all",
71
- "prepublishOnly": "napi prepublish -t npm",
72
- "test": "ava",
59
+ "prepublishOnly": "napi prepublish",
73
60
  "version": "napi version"
74
61
  },
75
- "prettier": {
76
- "printWidth": 120,
77
- "semi": false,
78
- "trailingComma": "all",
79
- "singleQuote": true,
80
- "arrowParens": "always"
62
+ "repository": "git@github.com:Brooooooklyn/Image.git",
63
+ "devDependencies": {
64
+ "@napi-rs/cli": "^2.6.2"
81
65
  },
82
- "repository": "git@github.com:Brooooooklyn/imgquant.git",
66
+ "gitHead": "855bdd78141f967a1dd3de048c6364710a55c1ab",
83
67
  "optionalDependencies": {
84
- "@napi-rs/image-win32-x64-msvc": "1.0.0",
85
- "@napi-rs/image-darwin-x64": "1.0.0",
86
- "@napi-rs/image-linux-x64-gnu": "1.0.0",
87
- "@napi-rs/image-darwin-arm64": "1.0.0",
88
- "@napi-rs/image-android-arm64": "1.0.0",
89
- "@napi-rs/image-linux-arm64-gnu": "1.0.0",
90
- "@napi-rs/image-linux-arm64-musl": "1.0.0",
91
- "@napi-rs/image-linux-arm-gnueabihf": "1.0.0",
92
- "@napi-rs/image-linux-x64-musl": "1.0.0",
93
- "@napi-rs/image-freebsd-x64": "1.0.0",
94
- "@napi-rs/image-win32-ia32-msvc": "1.0.0",
95
- "@napi-rs/image-android-arm-eabi": "1.0.0"
68
+ "@napi-rs/image-win32-x64-msvc": "1.1.2",
69
+ "@napi-rs/image-darwin-x64": "1.1.2",
70
+ "@napi-rs/image-linux-x64-gnu": "1.1.2",
71
+ "@napi-rs/image-darwin-arm64": "1.1.2",
72
+ "@napi-rs/image-android-arm64": "1.1.2",
73
+ "@napi-rs/image-linux-arm64-gnu": "1.1.2",
74
+ "@napi-rs/image-linux-arm64-musl": "1.1.2",
75
+ "@napi-rs/image-linux-arm-gnueabihf": "1.1.2",
76
+ "@napi-rs/image-linux-x64-musl": "1.1.2",
77
+ "@napi-rs/image-freebsd-x64": "1.1.2",
78
+ "@napi-rs/image-win32-ia32-msvc": "1.1.2",
79
+ "@napi-rs/image-android-arm-eabi": "1.1.2"
96
80
  }
97
81
  }
package/.gitattributes DELETED
@@ -1,13 +0,0 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
3
-
4
-
5
- *.ts text eol=lf merge=union
6
- *.tsx text eol=lf merge=union
7
- *.rs text eol=lf merge=union
8
- *.js text eol=lf merge=union
9
- *.json text eol=lf merge=union
10
- *.debug text eol=lf merge=union
11
-
12
- index.js linguist-detectable=false
13
- index.d.ts inguist-detectable=false