@depup/imagemin 9.0.1-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,37 @@
1
+ # @depup/imagemin
2
+
3
+ > Dependency-bumped version of [imagemin](https://www.npmjs.com/package/imagemin)
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
12
+ ```
13
+
14
+ | Field | Value |
15
+ |-------|-------|
16
+ | Original | [imagemin](https://www.npmjs.com/package/imagemin) @ 9.0.1 |
17
+ | Processed | 2026-03-17 |
18
+ | Smoke test | passed |
19
+ | Deps updated | 7 |
20
+
21
+ ## Dependency Changes
22
+
23
+ | Dependency | From | To |
24
+ |------------|------|-----|
25
+ | change-file-extension | ^0.1.1 | ^1.0.0 |
26
+ | environment | ^1.0.0 | ^1.1.0 |
27
+ | file-type | ^19.0.0 | ^21.3.3 |
28
+ | globby | ^14.0.1 | ^16.1.1 |
29
+ | image-dimensions | ^2.3.0 | ^2.5.0 |
30
+ | ow | ^2.0.0 | ^3.1.1 |
31
+ | uint8array-extras | ^1.1.0 | ^1.5.0 |
32
+
33
+ ---
34
+
35
+ Source: https://github.com/depup/npm | Original: https://www.npmjs.com/package/imagemin
36
+
37
+ License inherited from the original package.
package/changes.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "bumped": {
3
+ "change-file-extension": {
4
+ "from": "^0.1.1",
5
+ "to": "^1.0.0"
6
+ },
7
+ "environment": {
8
+ "from": "^1.0.0",
9
+ "to": "^1.1.0"
10
+ },
11
+ "file-type": {
12
+ "from": "^19.0.0",
13
+ "to": "^21.3.3"
14
+ },
15
+ "globby": {
16
+ "from": "^14.0.1",
17
+ "to": "^16.1.1"
18
+ },
19
+ "image-dimensions": {
20
+ "from": "^2.3.0",
21
+ "to": "^2.5.0"
22
+ },
23
+ "ow": {
24
+ "from": "^2.0.0",
25
+ "to": "^3.1.1"
26
+ },
27
+ "uint8array-extras": {
28
+ "from": "^1.1.0",
29
+ "to": "^1.5.0"
30
+ }
31
+ },
32
+ "timestamp": "2026-03-17T19:31:11.928Z",
33
+ "totalUpdated": 7
34
+ }
package/index.js ADDED
@@ -0,0 +1,83 @@
1
+ import fsPromises from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import {fileTypeFromBuffer} from 'file-type';
4
+ import {globby} from 'globby';
5
+ import pPipe from 'p-pipe';
6
+ import changeFileExtension from 'change-file-extension';
7
+ import {isNotJunk} from 'junk';
8
+ import convertToUnixPath from 'slash';
9
+ import {assertUint8Array} from 'uint8array-extras';
10
+ import {isBrowser} from 'environment';
11
+ import ow from 'ow';
12
+ import {imageDimensionsFromData} from 'image-dimensions';
13
+
14
+ const handleFile = async (sourcePath, {destination, plugins = []}) => {
15
+ ow(plugins, ow.optional.array.message('The `plugins` option should be an `Array`'));
16
+
17
+ let data = await fsPromises.readFile(sourcePath);
18
+
19
+ const dimensions = imageDimensionsFromData(data);
20
+ if (dimensions === undefined || (dimensions.width !== 0 && dimensions.height !== 0)) {
21
+ data = await (plugins.length > 0 ? pPipe(...plugins)(data) : data);
22
+ }
23
+
24
+ const {ext} = await fileTypeFromBuffer(data) ?? {ext: path.extname(sourcePath)};
25
+ let destinationPath = destination ? path.join(destination, path.basename(sourcePath)) : undefined;
26
+ destinationPath = ext === 'webp' && destinationPath
27
+ ? changeFileExtension(destinationPath, 'webp')
28
+ : destinationPath;
29
+
30
+ const returnValue = {
31
+ data: new Uint8Array(data),
32
+ sourcePath,
33
+ destinationPath,
34
+ };
35
+
36
+ if (!destinationPath) {
37
+ return returnValue;
38
+ }
39
+
40
+ await fsPromises.mkdir(path.dirname(returnValue.destinationPath), {recursive: true});
41
+ await fsPromises.writeFile(returnValue.destinationPath, returnValue.data);
42
+
43
+ return returnValue;
44
+ };
45
+
46
+ export default async function imagemin(input, {glob = true, ...options} = {}) {
47
+ if (isBrowser) {
48
+ throw new Error('This package does not work in the browser.');
49
+ }
50
+
51
+ ow(input, ow.array);
52
+
53
+ const unixFilePaths = input.map(path => convertToUnixPath(path));
54
+ const filePaths = glob ? await globby(unixFilePaths, {onlyFiles: true}) : input;
55
+
56
+ return Promise.all(
57
+ filePaths
58
+ .filter(filePath => isNotJunk(path.basename(filePath)))
59
+ .map(async filePath => {
60
+ try {
61
+ return await handleFile(filePath, options);
62
+ } catch (error) {
63
+ error.message = `Error occurred when handling file: ${input}\n\n${error.stack}`;
64
+ throw error;
65
+ }
66
+ }),
67
+ );
68
+ }
69
+
70
+ imagemin.buffer = async (data, {plugins = []} = {}) => {
71
+ if (isBrowser) {
72
+ throw new Error('This package does not work in the browser.');
73
+ }
74
+
75
+ assertUint8Array(data);
76
+
77
+ if (plugins.length === 0) {
78
+ return new Uint8Array(data);
79
+ }
80
+
81
+ // The `new Uint8Array` can be removed if all plugins are changed to return `Uint8Array` instead of `Buffer`.
82
+ return new Uint8Array(await pPipe(...plugins)(data));
83
+ };
package/license ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Imagemin (github.com/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,94 @@
1
+ {
2
+ "name": "@depup/imagemin",
3
+ "version": "9.0.1-depup.0",
4
+ "description": "[DepUp] Minify images seamlessly",
5
+ "license": "MIT",
6
+ "repository": "imagemin/imagemin",
7
+ "funding": "https://github.com/sponsors/sindresorhus",
8
+ "type": "module",
9
+ "exports": "./index.js",
10
+ "engines": {
11
+ "node": ">=18"
12
+ },
13
+ "scripts": {
14
+ "test": "xo && ava"
15
+ },
16
+ "files": [
17
+ "index.js",
18
+ "changes.json",
19
+ "README.md"
20
+ ],
21
+ "keywords": [
22
+ "depup",
23
+ "dependency-bumped",
24
+ "updated-deps",
25
+ "imagemin",
26
+ "minify",
27
+ "compress",
28
+ "image",
29
+ "images",
30
+ "jpeg",
31
+ "jpg",
32
+ "png",
33
+ "gif",
34
+ "svg"
35
+ ],
36
+ "dependencies": {
37
+ "change-file-extension": "^1.0.0",
38
+ "environment": "^1.1.0",
39
+ "file-type": "^21.3.3",
40
+ "globby": "^16.1.1",
41
+ "image-dimensions": "^2.5.0",
42
+ "junk": "^4.0.1",
43
+ "ow": "^3.1.1",
44
+ "p-pipe": "^4.0.0",
45
+ "slash": "^5.1.0",
46
+ "uint8array-extras": "^1.5.0"
47
+ },
48
+ "devDependencies": {
49
+ "ava": "^6.1.2",
50
+ "del": "^7.1.0",
51
+ "imagemin-jpegtran": "^7.0.0",
52
+ "imagemin-svgo": "^11.0.1",
53
+ "imagemin-webp": "^8.0.0",
54
+ "tempy": "^3.1.0",
55
+ "xo": "^0.58.0"
56
+ },
57
+ "depup": {
58
+ "changes": {
59
+ "change-file-extension": {
60
+ "from": "^0.1.1",
61
+ "to": "^1.0.0"
62
+ },
63
+ "environment": {
64
+ "from": "^1.0.0",
65
+ "to": "^1.1.0"
66
+ },
67
+ "file-type": {
68
+ "from": "^19.0.0",
69
+ "to": "^21.3.3"
70
+ },
71
+ "globby": {
72
+ "from": "^14.0.1",
73
+ "to": "^16.1.1"
74
+ },
75
+ "image-dimensions": {
76
+ "from": "^2.3.0",
77
+ "to": "^2.5.0"
78
+ },
79
+ "ow": {
80
+ "from": "^2.0.0",
81
+ "to": "^3.1.1"
82
+ },
83
+ "uint8array-extras": {
84
+ "from": "^1.1.0",
85
+ "to": "^1.5.0"
86
+ }
87
+ },
88
+ "depsUpdated": 7,
89
+ "originalPackage": "imagemin",
90
+ "originalVersion": "9.0.1",
91
+ "processedAt": "2026-03-17T19:31:36.329Z",
92
+ "smokeTest": "passed"
93
+ }
94
+ }
package/readme.md ADDED
@@ -0,0 +1,90 @@
1
+ # imagemin
2
+
3
+ > Minify images seamlessly
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install imagemin
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```js
14
+ import imagemin from 'imagemin';
15
+ import imageminJpegtran from 'imagemin-jpegtran';
16
+ import imageminPngquant from 'imagemin-pngquant';
17
+
18
+ const files = await imagemin(['images/*.{jpg,png}'], {
19
+ destination: 'build/images',
20
+ plugins: [
21
+ imageminJpegtran(),
22
+ imageminPngquant({
23
+ quality: [0.6, 0.8]
24
+ })
25
+ ]
26
+ });
27
+
28
+ console.log(files);
29
+ //=> [{data: <Uint8Array 89 50 4e …>, destinationPath: 'build/images/foo.jpg'}, …]
30
+ ```
31
+
32
+ ## API
33
+
34
+ ### imagemin(input, options?)
35
+
36
+ Returns `Promise<object[]>` in the format `{data: Uint8Array, sourcePath: string, destinationPath: string}`.
37
+
38
+ #### input
39
+
40
+ Type: `string[]`
41
+
42
+ File paths or [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
43
+
44
+ #### options
45
+
46
+ Type: `object`
47
+
48
+ ##### destination
49
+
50
+ Type: `string`
51
+
52
+ Set the destination folder to where your files will be written. If no destination is specified, no files will be written.
53
+
54
+ ##### plugins
55
+
56
+ Type: `Array`
57
+
58
+ The [plugins](https://www.npmjs.com/browse/keyword/imageminplugin) to use.
59
+
60
+ ##### glob
61
+
62
+ Type: `boolean`\
63
+ Default: `true`
64
+
65
+ Enable globbing when matching file paths.
66
+
67
+ ### imagemin.buffer(data, options?)
68
+
69
+ Returns `Promise<Uint8Array>`.
70
+
71
+ #### data
72
+
73
+ Type: `Uint8Array`
74
+
75
+ The image data to optimize.
76
+
77
+ #### options
78
+
79
+ Type: `object`
80
+
81
+ ##### plugins
82
+
83
+ Type: `Array`
84
+
85
+ [Plugins](https://www.npmjs.com/browse/keyword/imageminplugin) to use.
86
+
87
+ ## Related
88
+
89
+ - [imagemin-cli](https://github.com/imagemin/imagemin-cli) - CLI for this module
90
+ - [gulp-imagemin](https://github.com/sindresorhus/gulp-imagemin) - Gulp plugin