@napi-rs/image 1.1.2 → 1.2.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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/index.d.ts +11 -21
  3. package/package.json +14 -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 | No | ✅ |
23
- | AVIF | No | ✅ |
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 |
package/index.d.ts CHANGED
@@ -55,7 +55,7 @@ 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) */
@@ -67,11 +67,7 @@ export interface JpegCompressOptions {
67
67
  optimizeScans?: boolean | undefined | null
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,7 +98,7 @@ 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` */
@@ -155,11 +151,7 @@ export interface PNGLosslessOptions {
155
151
  useHeuristics?: boolean | undefined | null
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
157
  minQuality?: number | undefined | null
@@ -178,11 +170,7 @@ export interface PngQuantOptions {
178
170
  posterization?: number | undefined | null
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,7 +282,7 @@ 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
@@ -362,6 +350,8 @@ 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
365
355
  /**
366
356
  * The quality factor `quality_factor` ranges from 0 to 100 and controls the loss and quality during compression.
367
357
  * 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.1.2",
3
+ "version": "1.2.0",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "description": "Image processing library",
@@ -63,19 +63,19 @@
63
63
  "devDependencies": {
64
64
  "@napi-rs/cli": "^2.6.2"
65
65
  },
66
- "gitHead": "855bdd78141f967a1dd3de048c6364710a55c1ab",
66
+ "gitHead": "dfcd5d09749c394ba939ee72534e36c70d4cc445",
67
67
  "optionalDependencies": {
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"
68
+ "@napi-rs/image-win32-x64-msvc": "1.2.0",
69
+ "@napi-rs/image-darwin-x64": "1.2.0",
70
+ "@napi-rs/image-linux-x64-gnu": "1.2.0",
71
+ "@napi-rs/image-darwin-arm64": "1.2.0",
72
+ "@napi-rs/image-android-arm64": "1.2.0",
73
+ "@napi-rs/image-linux-arm64-gnu": "1.2.0",
74
+ "@napi-rs/image-linux-arm64-musl": "1.2.0",
75
+ "@napi-rs/image-linux-arm-gnueabihf": "1.2.0",
76
+ "@napi-rs/image-linux-x64-musl": "1.2.0",
77
+ "@napi-rs/image-freebsd-x64": "1.2.0",
78
+ "@napi-rs/image-win32-ia32-msvc": "1.2.0",
79
+ "@napi-rs/image-android-arm-eabi": "1.2.0"
80
80
  }
81
81
  }