1.0.16 • Published 2 years ago

image-optimist v1.0.16

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

image-optimist

A utility for processing and converting images to the requirements of the modern web.

Features

  • Recursive directory optimization
  • Keeping the original directory hierarchy
  • Flexible behavior customization

Install

$ npm install --save-dev image-optimist

Usage

const path = require('path');
const imageOptimist = require('image-optimist');

(async () => {
    await imageOptimist({
        sourcePath: path.join(__dirname, 'from'),
        destinationPath: path.join(__dirname, 'to'),
    });
})();

API

imageOptimist(config)

Returns Promise<void>.

config

Type: Object

sourcePath

Type: String

Set the source folder. Keep in mind that the subfolders will be included in the processing and the output files will retain their original hierarchy.

destinationPath

Type: String

Set the destination folder. The folder does not need to be empty, but images with the same name will be overwritten.

smartMode?

Type: Boolean Default true

If true, moves the file if there is no file with the same name in the destination folder, or if the processed file is smaller.

overwriteMode?

Type: Boolean Default false

If true, only existing files in the destination folder will be overwritten. If your destination folder is empty, there will be no changes (because nothing to update). Only available when smartMode is enabled.

ignoreConflicts?

Type: Boolean Default false

If true, disables checking that the source file and the file in the destination folder do not match. True is recommended only if you don't care about files in the destination folder.

Note: In most cases, you should replace an obsolete file with a more recent one to avoid erroneous overwriting.

mask?

Type: String Default: '*.{jpg,jpeg,png,svg,gif}'

See Glob patterns.

webp?

Type: Array || Boolean Default: [imageminWebp()]

By default, the optimal settings for generating WebP images are passed to the imageminWebp instance (see package source code for details). You can pass in your imageminWebp instance with the desired settings, or pass false if you want to disable the generation of images in WebP format.

plugins?

Type: Array Default: [imageminMozjpeg(), imageminPngquant(), imageminSvgo(), imageminGifsicle()]

By default, optimal settings are passed to plugin instances (see package source code for details). You can pass your array with the plugins and settings you want.

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago