0.1.2 • Published 2 years ago

compactor v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

compactor

Compress pdf and img on browser.

npm i compactor or yarn add compactor

Demo page: Demo Page

Example project with react: Example Project

Usage

compressFile args

compressFile = (inputFile, callbackFunc, options) => {...}

example inputFile

const base64StringWithPrefix = "data:image/jpeg;base64,/9j/4AAQSkZ...";
const base64StringWithoutPrefix = "/9j/4AAQSkZ...";

const inputFile = {
    bytes: base64StringWithoutPrefix, // remove prefix before use
    fileName: "example_image.jpeg",
    fileSize: 102400,
    mimeType: "image/jpeg"
}

example callbackFunc

const [compressedFile, setCompressedFile] = useState(null);

const callbackFunc = (file) => {
    setCompressedFile(file);
}

example options

const options = {
    pageScale: 1.0,   // use between 0-2
    pageQuality: 0.75 // use between 0-1
}

function call

import {compressFile} from "compactor";

await compressFile(inputFile, callbackFunc, options);

License

This project is licensed under the MIT License - see the LICENSE.md file for details

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago