Skip to content

👇 A tool to compress images to target size via canvas in browser

License

Notifications You must be signed in to change notification settings

Hitsuki9/pressor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pressor

Pressor is a tool to compress images to target size via canvas in browser

Installing

npm install pressor
# or
yarn add pressor
# or
pnpm add pressor

Usage

compress:

The function signature of compress is:

function compress(file: File, limit: number, accuracy: number): Promise<File>;
  • file: the image file which will be compressed
  • limit: the target size of the compressed file in kb, default to 500
  • accuracy: the accuracy of produced file size, default to 0.8

example:

import { compress } from 'pressor';

const inputChangeHandler = async (evt) => {
  const file = evt.target.files[0];
  const result = await compress(file);
};

About

👇 A tool to compress images to target size via canvas in browser

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published