You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

compressorjs

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compressorjs

JavaScript image compressor.

1.2.1
latest
Source
npmnpm
Version published
Weekly downloads
189K
-5.54%
Maintainers
1
Weekly downloads
 
Created

What is compressorjs?

Compressorjs is a JavaScript library that allows you to compress images in the browser. It is useful for reducing the size of images before uploading them to a server, which can save bandwidth and improve performance.

What are compressorjs's main functionalities?

Image Compression

This feature allows you to compress an image file by specifying the quality of the output image. The 'success' callback provides the compressed image file, while the 'error' callback handles any errors that occur during compression.

const compressor = new Compressor(file, {
  quality: 0.6,
  success(result) {
    console.log(result);
  },
  error(err) {
    console.error(err.message);
  },
});

Resize Image

This feature allows you to resize an image by specifying the maximum width and height. The 'success' callback provides the resized image file, while the 'error' callback handles any errors that occur during resizing.

const compressor = new Compressor(file, {
  maxWidth: 800,
  maxHeight: 600,
  success(result) {
    console.log(result);
  },
  error(err) {
    console.error(err.message);
  },
});

Convert Image Format

This feature allows you to convert the image format by specifying the desired MIME type. The 'success' callback provides the converted image file, while the 'error' callback handles any errors that occur during conversion.

const compressor = new Compressor(file, {
  mimeType: 'image/jpeg',
  success(result) {
    console.log(result);
  },
  error(err) {
    console.error(err.message);
  },
});

Other packages similar to compressorjs

Keywords

image

FAQs

Package last updated on 28 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts