Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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
  • npm
  • Socket score

Version published
Weekly downloads
162K
decreased by-2.13%
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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc