0.2.1 • Published 3 years ago
pressor v0.2.1
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 pressorUsage
compress:
The function signature of compress is:
function compress(file: File, limit: number, accuracy: number): Promise<File>;file: the image file which will be compressedlimit: the target size of the compressed file in kb, default to500accuracy: the accuracy of produced file size, default to0.8
example:
import { compress } from 'pressor';
const inputChangeHandler = async (evt) => {
const file = evt.target.files[0];
const result = await compress(file);
};