@depup/imagemin-pngquant 10.0.0-depup.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 ADDED
@@ -0,0 +1,34 @@
1
+ # @depup/imagemin-pngquant
2
+
3
+ > Dependency-bumped version of [imagemin-pngquant](https://www.npmjs.com/package/imagemin-pngquant)
4
+
5
+ Generated by [DepUp](https://github.com/depup/npm) -- all production
6
+ dependencies bumped to latest versions.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @depup/imagemin-pngquant
12
+ ```
13
+
14
+ | Field | Value |
15
+ |-------|-------|
16
+ | Original | [imagemin-pngquant](https://www.npmjs.com/package/imagemin-pngquant) @ 10.0.0 |
17
+ | Processed | 2026-03-19 |
18
+ | Smoke test | passed |
19
+ | Deps updated | 4 |
20
+
21
+ ## Dependency Changes
22
+
23
+ | Dependency | From | To |
24
+ |------------|------|-----|
25
+ | environment | ^1.0.0 | ^1.1.0 |
26
+ | execa | ^8.0.1 | ^9.6.1 |
27
+ | ow | ^2.0.0 | ^3.1.1 |
28
+ | uint8array-extras | ^1.1.0 | ^1.5.0 |
29
+
30
+ ---
31
+
32
+ Source: https://github.com/depup/npm | Original: https://www.npmjs.com/package/imagemin-pngquant
33
+
34
+ License inherited from the original package.
package/changes.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "bumped": {
3
+ "environment": {
4
+ "from": "^1.0.0",
5
+ "to": "^1.1.0"
6
+ },
7
+ "execa": {
8
+ "from": "^8.0.1",
9
+ "to": "^9.6.1"
10
+ },
11
+ "ow": {
12
+ "from": "^2.0.0",
13
+ "to": "^3.1.1"
14
+ },
15
+ "uint8array-extras": {
16
+ "from": "^1.1.0",
17
+ "to": "^1.5.0"
18
+ }
19
+ },
20
+ "timestamp": "2026-03-19T03:28:27.678Z",
21
+ "totalUpdated": 4
22
+ }
package/index.d.ts ADDED
@@ -0,0 +1,58 @@
1
+ export interface Options { // eslint-disable-line @typescript-eslint/consistent-type-definitions
2
+ /**
3
+ Speed `10` has 5% lower quality, but is about 8 times faster than the default. Speed `11` disables dithering and lowers compression level.
4
+
5
+ Values: `1` (brute-force) to `11` (fastest)
6
+
7
+ @default 3
8
+ */
9
+ speed?: number;
10
+
11
+ /**
12
+ Remove optional metadata.
13
+
14
+ @default false
15
+ */
16
+ strip?: boolean;
17
+
18
+ /**
19
+ Instructs pngquant to use the least amount of colors required to meet or exceed the max quality. If conversion results in quality below the min quality the image won't be saved.
20
+
21
+ Min and max are numbers in range 0 (worst) to 1 (perfect), similar to JPEG.
22
+
23
+ Values: `[0...1, 0...1]`
24
+
25
+ @example [0.3, 0.5]
26
+ */
27
+ quality?: [number, number];
28
+
29
+ /**
30
+ Set the dithering level using a fractional number between 0 (none) and 1 (full).
31
+
32
+ Pass in `false` to disable dithering.
33
+
34
+ Values: 0...1
35
+
36
+ @default 1
37
+ */
38
+ dithering?: number | boolean;
39
+
40
+ /**
41
+ Truncate number of least significant bits of color (per channel).
42
+
43
+ Use this when image will be output on low-depth displays (e.g. 16-bit RGB). pngquant will make almost-opaque pixels fully opaque and will reduce amount of semi-transparent colors.
44
+ */
45
+ posterize?: number;
46
+ }
47
+
48
+ /**
49
+ Image data to optimize.
50
+ */
51
+ export type Plugin = (input: Uint8Array) => Promise<Uint8Array>;
52
+
53
+ /**
54
+ Imagemin plugin for pngquant.
55
+
56
+ @returns An Imagemin plugin.
57
+ */
58
+ export default function imageminPngquant(options?: Options): Plugin;
package/index.js ADDED
@@ -0,0 +1,77 @@
1
+ import {execa} from 'execa';
2
+ import isPng from 'is-png';
3
+ import pngquant from 'pngquant-bin';
4
+ import ow from 'ow';
5
+ import {isUint8Array} from 'uint8array-extras';
6
+ import {isBrowser} from 'environment';
7
+
8
+ export default function imageminPngquant(options = {}) {
9
+ if (isBrowser) {
10
+ throw new Error('This package does not work in the browser.');
11
+ }
12
+
13
+ return async input => {
14
+ const isData = isUint8Array(input);
15
+
16
+ if (!isUint8Array(input)) {
17
+ throw new TypeError(`Expected a Uint8Array, got ${typeof input}`);
18
+ }
19
+
20
+ if (isData && !isPng(input)) {
21
+ return input;
22
+ }
23
+
24
+ const arguments_ = ['-'];
25
+
26
+ if (options.speed !== undefined) {
27
+ ow(options.speed, ow.number.integer.inRange(1, 11));
28
+ arguments_.push('--speed', options.speed.toString());
29
+ }
30
+
31
+ if (options.strip !== undefined) {
32
+ ow(options.strip, ow.boolean);
33
+
34
+ if (options.strip) {
35
+ arguments_.push('--strip');
36
+ }
37
+ }
38
+
39
+ if (options.quality !== undefined) {
40
+ ow(options.quality, ow.array.length(2).ofType(ow.number.inRange(0, 1)));
41
+ const [min, max] = options.quality;
42
+ arguments_.push('--quality', `${Math.round(min * 100)}-${Math.round(max * 100)}`);
43
+ }
44
+
45
+ if (options.dithering !== undefined) {
46
+ ow(options.dithering, ow.any(ow.number.inRange(0, 1), ow.boolean.false));
47
+
48
+ if (typeof options.dithering === 'number') {
49
+ arguments_.push(`--floyd=${options.dithering}`);
50
+ } else if (options.dithering === false) {
51
+ arguments_.push('--ordered');
52
+ }
53
+ }
54
+
55
+ if (options.posterize !== undefined) {
56
+ ow(options.posterize, ow.number);
57
+ arguments_.push('--posterize', options.posterize.toString());
58
+ }
59
+
60
+ try {
61
+ const {stdout} = await execa(pngquant, arguments_, {
62
+ encoding: 'buffer',
63
+ maxBuffer: Number.POSITIVE_INFINITY,
64
+ input,
65
+ });
66
+
67
+ return stdout;
68
+ } catch (error) {
69
+ // Handling special condition from pngquant binary (status code 99).
70
+ if (error.exitCode === 99) {
71
+ return input;
72
+ }
73
+
74
+ throw error;
75
+ }
76
+ };
77
+ }
package/license ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Imagemin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@depup/imagemin-pngquant",
3
+ "version": "10.0.0-depup.0",
4
+ "description": "Imagemin plugin for `pngquant` (with updated dependencies)",
5
+ "license": "MIT",
6
+ "repository": "imagemin/imagemin-pngquant",
7
+ "type": "module",
8
+ "exports": {
9
+ "types": "./index.d.ts",
10
+ "default": "./index.js"
11
+ },
12
+ "engines": {
13
+ "node": ">=18"
14
+ },
15
+ "scripts": {
16
+ "test": "xo && npm run test:cover && tsc --noEmit index.d.ts",
17
+ "test:cover": "c8 --check-coverage --statements 90 ava"
18
+ },
19
+ "files": [
20
+ "index.js",
21
+ "index.d.ts",
22
+ "changes.json",
23
+ "README.md"
24
+ ],
25
+ "keywords": [
26
+ "imagemin-pngquant",
27
+ "depup",
28
+ "updated-dependencies",
29
+ "security",
30
+ "latest",
31
+ "patched",
32
+ "compress",
33
+ "image",
34
+ "imageminplugin",
35
+ "minify",
36
+ "optimize",
37
+ "png",
38
+ "pngquant"
39
+ ],
40
+ "dependencies": {
41
+ "environment": "^1.1.0",
42
+ "execa": "^9.6.1",
43
+ "is-png": "^3.0.1",
44
+ "ow": "^3.1.1",
45
+ "pngquant-bin": "^9.0.0",
46
+ "uint8array-extras": "^1.5.0"
47
+ },
48
+ "devDependencies": {
49
+ "@types/node": "^20.12.10",
50
+ "ava": "^6.1.3",
51
+ "c8": "^9.1.0",
52
+ "typescript": "^5.4.5",
53
+ "xo": "^0.58.0"
54
+ },
55
+ "depup": {
56
+ "changes": {
57
+ "environment": {
58
+ "from": "^1.0.0",
59
+ "to": "^1.1.0"
60
+ },
61
+ "execa": {
62
+ "from": "^8.0.1",
63
+ "to": "^9.6.1"
64
+ },
65
+ "ow": {
66
+ "from": "^2.0.0",
67
+ "to": "^3.1.1"
68
+ },
69
+ "uint8array-extras": {
70
+ "from": "^1.1.0",
71
+ "to": "^1.5.0"
72
+ }
73
+ },
74
+ "depsUpdated": 4,
75
+ "originalPackage": "imagemin-pngquant",
76
+ "originalVersion": "10.0.0",
77
+ "processedAt": "2026-03-19T03:28:43.273Z",
78
+ "smokeTest": "passed"
79
+ }
80
+ }
package/readme.md ADDED
@@ -0,0 +1,92 @@
1
+ # imagemin-pngquant
2
+
3
+ > [Imagemin](https://github.com/imagemin/imagemin) plugin for [`pngquant`](https://github.com/kornelski/pngquant)
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install imagemin-pngquant
9
+ ```
10
+
11
+ ### Prerequisites
12
+
13
+ > **Linux** machines must have the following packages prior to install: `libpng-dev libimagequant-dev`
14
+
15
+ ```sh
16
+ sudo apt-get -y install libpng-dev libimagequant-dev
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```js
22
+ import imagemin from 'imagemin';
23
+ import imageminPngquant from 'imagemin-pngquant';
24
+
25
+ await imagemin(['images/*.png'], {
26
+ destination: 'build/images',
27
+ plugins: [
28
+ imageminPngquant()
29
+ ]
30
+ });
31
+
32
+ console.log('Images optimized');
33
+ ```
34
+
35
+ ## API
36
+
37
+ ### imageminPngquant(options?)(input)
38
+
39
+ Returns `Promise<Uint8Array>`.
40
+
41
+ #### options
42
+
43
+ Type: `object`
44
+
45
+ ##### speed
46
+
47
+ Type: `number`\
48
+ Default: `4`\
49
+ Values: `1` (brute-force) to `11` (fastest)
50
+
51
+ Speed `10` has 5% lower quality, but is about 8 times faster than the default. Speed `11` disables dithering and lowers compression level.
52
+
53
+ ##### strip
54
+
55
+ Type: `boolean`\
56
+ Default: `false`
57
+
58
+ Remove optional metadata.
59
+
60
+ ##### quality
61
+
62
+ Type: `Array<min: number, max: number>`\
63
+ Values: `Array<0...1, 0...1>`\
64
+ Example: `[0.3, 0.5]`
65
+
66
+ Instructs pngquant to use the least amount of colors required to meet or exceed
67
+ the max quality. If conversion results in quality below the min quality the
68
+ image won't be saved.
69
+
70
+ Min and max are numbers in range 0 (worst) to 1 (perfect), similar to JPEG.
71
+
72
+ ##### dithering
73
+
74
+ Type: `number | boolean`\
75
+ Default: `1` (full)\
76
+ Values: `0...1`
77
+
78
+ Set the dithering level using a fractional number between 0 (none) and 1 (full).
79
+
80
+ Pass in `false` to disable dithering.
81
+
82
+ ##### posterize
83
+
84
+ Type: `number`
85
+
86
+ Truncate number of least significant bits of color (per channel). Use this when image will be output on low-depth displays (e.g. 16-bit RGB). pngquant will make almost-opaque pixels fully opaque and will reduce amount of semi-transparent colors.
87
+
88
+ #### input
89
+
90
+ Type: `Uint8Array`
91
+
92
+ Image data to optimize.