@napi-rs/image 1.4.1 → 1.4.4

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/index.d.ts +13 -3
  2. package/index.js +13 -2
  3. package/package.json +15 -15
package/index.d.ts CHANGED
@@ -102,6 +102,18 @@ export interface PngEncodeOptions {
102
102
  /** Default is `FilterType::NoFilter` */
103
103
  filterType?: FilterType
104
104
  }
105
+ export const enum PngRowFilter {
106
+ None = 0,
107
+ Sub = 1,
108
+ Up = 2,
109
+ Average = 3,
110
+ Paeth = 4,
111
+ MinSum = 5,
112
+ Entropy = 6,
113
+ Bigrams = 7,
114
+ BigEnt = 8,
115
+ Brute = 9
116
+ }
105
117
  export interface PNGLosslessOptions {
106
118
  /**
107
119
  * Attempt to fix errors when decoding the input file rather than returning an Err.
@@ -114,7 +126,7 @@ export interface PNGLosslessOptions {
114
126
  */
115
127
  force?: boolean
116
128
  /** Which filters to try on the file (0-5) */
117
- filter?: Array<number>
129
+ filter?: Array<PngRowFilter>
118
130
  /**
119
131
  * Whether to attempt bit depth reduction
120
132
  * Default: `true`
@@ -143,8 +155,6 @@ export interface PNGLosslessOptions {
143
155
  idatRecoding?: boolean
144
156
  /** Whether to remove ***All non-critical headers*** on PNG */
145
157
  strip?: boolean
146
- /** Whether to use heuristics to pick the best filter and compression */
147
- useHeuristics?: boolean
148
158
  }
149
159
  export function losslessCompressPngSync(input: Buffer, options?: PNGLosslessOptions | undefined | null): Buffer
150
160
  export function losslessCompressPng(input: Buffer, options?: PNGLosslessOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>
package/index.js CHANGED
@@ -11,7 +11,8 @@ function isMusl() {
11
11
  // For Node 10
12
12
  if (!process.report || typeof process.report.getReport !== 'function') {
13
13
  try {
14
- return readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
14
+ const lddPath = require('child_process').execSync('which ldd').toString().trim();
15
+ return readFileSync(lddPath, 'utf8').includes('musl')
15
16
  } catch (e) {
16
17
  return true
17
18
  }
@@ -101,6 +102,15 @@ switch (platform) {
101
102
  }
102
103
  break
103
104
  case 'darwin':
105
+ localFileExisted = existsSync(join(__dirname, 'image.darwin-universal.node'))
106
+ try {
107
+ if (localFileExisted) {
108
+ nativeBinding = require('./image.darwin-universal.node')
109
+ } else {
110
+ nativeBinding = require('@napi-rs/image-darwin-universal')
111
+ }
112
+ break
113
+ } catch {}
104
114
  switch (arch) {
105
115
  case 'x64':
106
116
  localFileExisted = existsSync(join(__dirname, 'image.darwin-x64.node'))
@@ -236,13 +246,14 @@ if (!nativeBinding) {
236
246
  throw new Error(`Failed to load native binding`)
237
247
  }
238
248
 
239
- const { ChromaSubsampling, compressJpegSync, compressJpeg, CompressionType, FilterType, losslessCompressPngSync, losslessCompressPng, pngQuantizeSync, pngQuantize, Orientation, ResizeFilterType, JsColorType, Transformer } = nativeBinding
249
+ const { ChromaSubsampling, compressJpegSync, compressJpeg, CompressionType, FilterType, PngRowFilter, losslessCompressPngSync, losslessCompressPng, pngQuantizeSync, pngQuantize, Orientation, ResizeFilterType, JsColorType, Transformer } = nativeBinding
240
250
 
241
251
  module.exports.ChromaSubsampling = ChromaSubsampling
242
252
  module.exports.compressJpegSync = compressJpegSync
243
253
  module.exports.compressJpeg = compressJpeg
244
254
  module.exports.CompressionType = CompressionType
245
255
  module.exports.FilterType = FilterType
256
+ module.exports.PngRowFilter = PngRowFilter
246
257
  module.exports.losslessCompressPngSync = losslessCompressPngSync
247
258
  module.exports.losslessCompressPng = losslessCompressPng
248
259
  module.exports.pngQuantizeSync = pngQuantizeSync
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@napi-rs/image",
3
- "version": "1.4.1",
3
+ "version": "1.4.4",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "description": "Image processing library",
@@ -61,21 +61,21 @@
61
61
  },
62
62
  "repository": "git@github.com:Brooooooklyn/Image.git",
63
63
  "devDependencies": {
64
- "@napi-rs/cli": "^2.12.0"
64
+ "@napi-rs/cli": "^2.14.1"
65
65
  },
66
- "gitHead": "8359de12827f78b32551df5c4bb76f6b2d06b718",
66
+ "gitHead": "fdd80a15bf0f215383c622a4361a3b74dd22bddd",
67
67
  "optionalDependencies": {
68
- "@napi-rs/image-win32-x64-msvc": "1.4.1",
69
- "@napi-rs/image-darwin-x64": "1.4.1",
70
- "@napi-rs/image-linux-x64-gnu": "1.4.1",
71
- "@napi-rs/image-darwin-arm64": "1.4.1",
72
- "@napi-rs/image-android-arm64": "1.4.1",
73
- "@napi-rs/image-linux-arm64-gnu": "1.4.1",
74
- "@napi-rs/image-linux-arm64-musl": "1.4.1",
75
- "@napi-rs/image-linux-arm-gnueabihf": "1.4.1",
76
- "@napi-rs/image-linux-x64-musl": "1.4.1",
77
- "@napi-rs/image-freebsd-x64": "1.4.1",
78
- "@napi-rs/image-win32-ia32-msvc": "1.4.1",
79
- "@napi-rs/image-android-arm-eabi": "1.4.1"
68
+ "@napi-rs/image-win32-x64-msvc": "1.4.4",
69
+ "@napi-rs/image-darwin-x64": "1.4.4",
70
+ "@napi-rs/image-linux-x64-gnu": "1.4.4",
71
+ "@napi-rs/image-darwin-arm64": "1.4.4",
72
+ "@napi-rs/image-android-arm64": "1.4.4",
73
+ "@napi-rs/image-linux-arm64-gnu": "1.4.4",
74
+ "@napi-rs/image-linux-arm64-musl": "1.4.4",
75
+ "@napi-rs/image-linux-arm-gnueabihf": "1.4.4",
76
+ "@napi-rs/image-linux-x64-musl": "1.4.4",
77
+ "@napi-rs/image-freebsd-x64": "1.4.4",
78
+ "@napi-rs/image-win32-ia32-msvc": "1.4.4",
79
+ "@napi-rs/image-android-arm-eabi": "1.4.4"
80
80
  }
81
81
  }