pretty-fast-image-resizer

2.3.1 • Public • Published

fast-image-resizer

A lightweight, dependency-rich library for fast and efficient image resizing in the browser.

Installation

To install the library, run the following command in your project directory:

npm install fast-image-resizer

Usage

Here's how to use the library to resize an image file:

  1. Import the resizeImage function from the library.

    import { resizeImage } from 'fast-image-resizer';
  2. Create an input element of type file in your HTML to allow the user to select an image to resize.

    <input type="file" id="imageInput" />
  3. Use the resizeImage function, passing the selected file and your desired options for width, height, and quality.

    document.getElementById('imageInput').addEventListener('change', function(event) {
    const file = event.target.files[0];
    if (file) {
    resizeImage(file, { width: 800, height: 600, quality: 0.9 });
    }
    });

API

resizeImage(file, options)

Resizes an image file and saves the result.

  • file: The image file to resize.
  • options: An object containing resize options.
    • width: The target width.
    • height: The target height.
    • quality (optional): The quality of the output image, default is 0.92.

Dependencies

This library uses several dependencies to handle image loading, resizing, and saving:

  • blueimp-load-image
  • pica
  • file-saver
  • mime-types
  • blob-util

License

This project is licensed under the ISC License.

Package Sidebar

Install

npm i pretty-fast-image-resizer

Weekly Downloads

0

Version

2.3.1

License

ISC

Unpacked Size

3.32 kB

Total Files

3

Last publish

Collaborators

  • yehorbohdanov