Coder Social home page Coder Social logo

imagemin

Minify images seamlessly





Install

$ npm install imagemin

Usage

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: <Buffer 89 50 4e …>, destinationPath: 'build/images/foo.jpg'}, …]

API

imagemin(input, options?)

Returns Promise<object[]> in the format {data: Buffer, sourcePath: string, destinationPath: string}.

input

Type: string[]

File paths or glob 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

Plugins to use.

glob

Type: boolean
Default: true

Enable globbing when matching file paths.

imagemin.buffer(buffer, options?)

Returns Promise<Buffer>.

buffer

Type: Buffer

Buffer to optimize.

options

Type: object

plugins

Type: Array

Plugins to use.

Related

imagemin's Projects

advpng-bin icon advpng-bin

AdvPNG bin-wrapper that makes it seamlessly available as a local dependency

cwebp-bin icon cwebp-bin

cwebp bin-wrapper that makes it seamlessly available as a local dependency

gif2webp-bin icon gif2webp-bin

gif2webp bin-wrapper that makes it seamlessly available as a local dependency

gifsicle-bin icon gifsicle-bin

gifsicle bin-wrapper that makes it seamlessly available as a local dependency

guetzli-bin icon guetzli-bin

guetzli wrapper that makes it seamlessly available as a local dependency

imagemin icon imagemin

[Unmaintained] Minify images seamlessly

jpeg-recompress-bin icon jpeg-recompress-bin

jpeg-recompress bin-wrapper that makes it seamlessly available as a local dependency

jpegoptim-bin icon jpegoptim-bin

jpegoptim bin-wrapper that makes it seamlessly available as a local dependency

jpegtran-bin icon jpegtran-bin

jpegtran bin-wrapper that makes it seamlessly available as a local dependency

meta icon meta

General discussion repo for imagemin related projects

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.