prims

0.2.0 • Public • Published

Prims

downloads-badge

A program built on top of sharp to batch processing images from an input directory. A simple way to generate responsive images.

  • Process multiple images.
  • Convert to jpeg, png, webp, tiff.
  • Resize to a list of specified widths and heights.
  • Fit image (cover, contain, fill, inside, outside).
  • Preserve or remove image metadata.
  • Customize naming convention.
  • Optional interactive CLI.
  • Lightweight (sharp is the only dependency).
  • Runs in nodejs v8 and up.

Install

npm install --save-dev prims

You can also install the optional prims-cli.

Quick Start

const prims = require('prims');
 
prims({
  input: path.resolve(__dirname, './images'),
  convert: {
    jpeg: {
      quality: 70
    },
    webp: {
      quality: 60
    }
  },
  resize: {
    widths: [ 400, 800 ]
  }
});
  • Read files inside images folder.
  • Convert images to jpeg at 70% quality and to webp at 60% quality.
  • Each converted images will also be resized to the selected resize.widths.
  • Because resize.heights is omitted, height for each image is calculated automatically to preserve aspect ratio.
  • Output all processed images to ./images/processed-images/.

Output:

  • [name]_400w.jpeg
  • [name]_400w.webp
  • [name]_800w.jpeg
  • [name]_800w.webp

Examples

Go to examples page.

API

Go to api page.

Test locally

yarn run test

See tests folder.

Contribution

Contributions are welcome.

Dependencies (1)

Dev Dependencies (1)

Package Sidebar

Install

npm i prims

Weekly Downloads

3

Version

0.2.0

License

Apache-2.0

Unpacked Size

33.8 kB

Total Files

19

Last publish

Collaborators

  • pldg