New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

imagemin-keep-folder

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imagemin-keep-folder

Minify images

5.3.2
latest
npm
Version published
Weekly downloads
4.1K
15.73%
Maintainers
1
Weekly downloads
 
Created
Source

Minify images seamlessly

Introduction

Fork form imagemin.

support keep and customize folder structure

Install

$ npm install --save-dev imagemin-keep-folder

Usage

// as usual
const imagemin = require('imagemin-keep-folder');

imagemin(['images/*.{jpg,png}'], 'build/images', {
	
}).then(files => {
	console.log(files);
	//=> [{data: <Buffer 89 50 4e …>, path: 'build/images/foo.jpg'}, …]
});
// keep folder structure as input
const imagemin = require('imagemin-keep-folder');

imagemin(['images/**/*.{jpg,png}'], {
  
});
// for example
// images/a.jpg => images/a.jpg
// images/foo/a.jpg => images/foo/a.jpg
// images/foo/bar/a.jpg => images/foo/bar/a.jpg
// keep folder structure as input use imagemin-webp
const imagemin = require('imagemin-keep-folder');
const imageminWebp = require("imagemin-webp");

imagemin(['images/**/*.{jpg,png}'], {
  use: [
    imageminWebp({})
  ]
});
// for example
// images/a.jpg => images/a.webp
// images/foo/a.jpg => images/foo/a.webp
// images/foo/bar/a.jpg => images/foo/bar/a.webp
// customize folder structure as input use imagemin-webp
const imagemin = require('imagemin-keep-folder');
const imageminWebp = require("imagemin-webp");

imagemin(['images/**/*.{jpg,png}'], {
  use: [
    imageminWebp({})
  ],
  replaceOutputDir: output => {
    return output.replace(/images\//, '.webp/')
  }
});
// for example
// images/a.jpg => .webp/a.webp
// images/foo/a.jpg => .webp/foo/a.webp
// images/foo/bar/a.jpg => .webp/foo/bar/a.webp

API

same as imagemin

imagemin(input, output, [options])

Returns Promise<Object[]> in the format {data: Buffer, path: String}.

input

Type: Array

Files to be optimized. See supported minimatch patterns.

output

Type: string

Set the destination folder to where your files will be written. If no destination is specified no files will be written. If no destination is specified, files will be written and keep folder structure

options

Type: Object

replaceOutputDir (new options)

Type: Function

Returns String (new output dir)

plugins

Type: Array

Plugins to use.

imagemin.buffer(buffer, [options])

Returns Promise<Buffer>.

buffer

Type: Buffer

Buffer to optimize.

options

Type: Object

plugins

Type: Array

Plugins to use.

License

MIT © imagemin

Keywords

minify

FAQs

Package last updated on 19 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts