1.0.0 • Published 3 months ago

@seam-hossain/img-resizer v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

img-resizer

img-resizer is a lightweight JavaScript module for effortlessly resizing images and adjusting image quality. Optimize storage and reduce loading times with ease.

Installation

npm i img-resizer

Example Usage

As a JavaScript Module

Import and use the module in your JavaScript and typeScript code:

// Import the resizeImage function from 'img-resizer'
import { resizeImage } from 'img-resizer';

// State declaration
const [image, setImage] = useState(null);

// Function to handle image change
const handleImageChange = (e) => {
  // Retrieve the selected image from the input element
  const selectedImage = e.target.files[0];
  
  // Call the resizeImage function with the selected image, desired width, quality, and a callback function to set the resized image
  resizeImage(selectedImage, width, quality, (resizedImage) => {
    // Set the resized image as the state
    setImage(resizedImage);
  });
};
1.0.0

3 months ago