/nodejs-image-squeezer

A simple NodeJS package for image compression powered by FFMPEG.

Primary LanguageTypeScriptMIT LicenseMIT

NodeJS Image Squeezer

A simple NodeJS package for image compression powered by FFMPEG.

Build Status Coverage Status NPM version

Requirement(s)

  • Node.js 8.0.* up to latest.

  • Operating System: Windows, Linux.

  • FFMPEG Binaries or Executable File:

Install

via NPM

  • Use the command below to install the package via npm:
npm install nodejs-image-squeezer --save

Usage

  • Below are the simple implementation of the package using TypeScript:
// Import the main class of the NodeJS Image Squeezer.
import ImageSqueezer from 'nodejs-image-squeezer';

// Initialize the main class.
var imageSqueezer = new ImageSqueezer();

// Load the necessary requirements and validate
// if the package fit for the current environment.
imageSqueezer.load();

// Set the path of binary file of ffmpeg.
imageSqueezer.setFFMpegBin('/path/to/binary');

// Provide the source file path of the desire image
// that will be compress later on.
imageSqueezer.setSourceFilePath('/path/source-filename');

// Provide the output file path of the compressed image.
imageSqueezer.setOutputFilePath('/path/output-filename');

// Execute the image compression.
imageSqueezer.compress();
  • Basic implementation of the package without superset libraries of JavaScript (using a pure Node.js syntax):
// Require the main class of the NodeJS Image Squeezer.
var ImageSqueezer = require('nodejs-image-squeezer');

// Initialize the main class.
var imageSqueezer = new ImageSqueezer();

// Load the necessary requirements and validate
// if the package fit for the current environment.
imageSqueezer.load();

// Set the path of binary file of ffmpeg.
imageSqueezer.setFFMpegBin('/path/to/binary');

// Provide the source file path of the desire image
// that will be compress later on.
imageSqueezer.setSourceFilePath('/path/source-filename');

// Provide the output file path of the compressed image.
imageSqueezer.setOutputFilePath('/path/output-filename');

// Execute the image compression.
imageSqueezer.compress();

License

This package is open-sourced software licensed under the MIT license.