npm.io
1.0.2 • Published 2 years ago

tiny-image-compression-tool

Licence
ISC
Version
1.0.2
Deps
3
Size
4 kB
Vulns
4
Weekly
0
Stars
1

tiny-image-compression-tool

A lightweight Node.js library for compressing images using Sharp and imagemin.

Installation

You can install tiny-image-compression-tool via npm:

npm install tiny-image-compression-tool

Usage

const { compressImages } = require('tiny-image-compression-tool');

// Path to the images you want to compress
const imagesPath = './images/*.{jpg,png}';
// Directory to save the compressed images
const outputDirectory = './compressed';

// Compress images with default width (800px)
compressImages(imagesPath, outputDirectory)
  .then(() => console.log('Images compressed successfully'))
  .catch((error) => console.error('Error compressing images:', error));

// You can also specify a custom width for resizing the images
const customWidth = 600;
compressImages(imagesPath, outputDirectory, customWidth)
  .then(() => console.log('Images compressed successfully with custom width'))
  .catch((error) => console.error('Error compressing images:', error));

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords