pretty-fast-image-resizer
v2.3.1
Published
A lightweight, dependency-rich library for fast and efficient image resizing in the browser.
Downloads
1
Maintainers
Readme
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:
Import the
resizeImage
function from the library.import { resizeImage } from 'fast-image-resizer';
Create an
input
element of typefile
in your HTML to allow the user to select an image to resize.<input type="file" id="imageInput" />
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.