Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/imagemin/imagemin
Minify images seamlessly
https://github.com/imagemin/imagemin
buffer gif imagemin jpg minify nodejs optimization png svg
Last synced: 3 days ago
JSON representation
Minify images seamlessly
- Host: GitHub
- URL: https://github.com/imagemin/imagemin
- Owner: imagemin
- License: mit
- Created: 2013-11-04T09:26:16.000Z (about 11 years ago)
- Default Branch: main
- Last Pushed: 2024-09-08T18:28:30.000Z (3 months ago)
- Last Synced: 2024-10-14T04:31:27.166Z (about 2 months ago)
- Topics: buffer, gif, imagemin, jpg, minify, nodejs, optimization, png, svg
- Language: JavaScript
- Homepage:
- Size: 746 KB
- Stars: 5,561
- Watchers: 60
- Forks: 259
- Open Issues: 78
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
- awesome-nodejs-cn - imagemin - Image 压缩工具 (包 / 代码压缩)
- Front-End-Checklist - Imagemin
- Front-End-Checklist - Imagemin
- awesome-nodejs - imagemin - Image minifier. ![](https://img.shields.io/github/stars/imagemin/imagemin.svg?style=social&label=Star) (Repository / Minifiers)
- awesome-nodejs-cn - imagemin - **star:5574** 图像缩小镜 ![star > 2000][Awesome] (包 / 代码压缩)
- awesome-github-star - imagemin
- awesome-nodejs - imagemin - Image minifier. (Packages / Minifiers)
- awesome-node - imagemin - Image minifier. (Packages / Minifiers)
- awesome-nodejs-cn - imagemin - Image压缩工具. (目录 / 文件压缩)
- awesome-star-libs - imagemin / imagemin
- awesome - imagemin/imagemin - Minify images seamlessly (JavaScript)
- awesome-nodejs - imagemin - Image 压缩工具。 ![](https://img.shields.io/github/stars/imagemin/imagemin.svg?style=social&label=Star) (GIT 仓库 / 最小化)
- awesome-nodejs - imagemin - Tense, nervous, minifying images? - ★ 2584 (Minifiers)
README
# imagemin
> Minify images seamlessly
## Install
```sh
npm install imagemin
```## Usage
```js
import imagemin from 'imagemin';
import imageminJpegtran from 'imagemin-jpegtran';
import imageminPngquant from 'imagemin-pngquant';const files = await imagemin(['images/*.{jpg,png}'], {
destination: 'build/images',
plugins: [
imageminJpegtran(),
imageminPngquant({
quality: [0.6, 0.8]
})
]
});console.log(files);
//=> [{data: , destinationPath: 'build/images/foo.jpg'}, …]
```## API
### imagemin(input, options?)
Returns `Promise` in the format `{data: Uint8Array, sourcePath: string, destinationPath: string}`.
#### input
Type: `string[]`
File paths or [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
#### options
Type: `object`
##### destination
Type: `string`
Set the destination folder to where your files will be written. If no destination is specified, no files will be written.
##### plugins
Type: `Array`
The [plugins](https://www.npmjs.com/browse/keyword/imageminplugin) to use.
##### glob
Type: `boolean`\
Default: `true`Enable globbing when matching file paths.
### imagemin.buffer(data, options?)
Returns `Promise`.
#### data
Type: `Uint8Array`
The image data to optimize.
#### options
Type: `object`
##### plugins
Type: `Array`
[Plugins](https://www.npmjs.com/browse/keyword/imageminplugin) to use.
## Related
- [imagemin-cli](https://github.com/imagemin/imagemin-cli) - CLI for this module
- [gulp-imagemin](https://github.com/sindresorhus/gulp-imagemin) - Gulp plugin