7.0.10 • Published 5 months ago
compress-base64 v7.0.10
compress-base64
A library for compressing base64 in browser environment.
install
npm i compress-base64
or
yarn add compress-base64
or
pnpm add compress-base64
usage
options
es
For example.
import compress from 'compress-base64';
if (typeof FileReader === 'function') {
const reader = new FileReader();
reader.onload = (event) => {
compress(event.target.result, {
width: 400,
type: 'image/png',
max: 200, // max size
min: 20, // min size
quality: 0.8,
}).then((result) => {
console.log(result);
});
};
reader.readAsDataURL(file);
} else {
alert('Your browser does not support FileReader');
}
browser
Introduce this resource.
<script src="https://unpkg.com/compress-base64@latest"></script>
You can also download this resource locally and then import it.
<script src="/path/compress-base64/umd/index.js"></script>
Use it.
if (typeof FileReader === 'function') {
const reader = new FileReader();
reader.onload = (event) => {
window.CompressBase64.default(event.target.result, {
width: 100,
type: 'image/png',
max: 7, // max size
min: 5,
quality: 0.8,
}).then((result) => {
console.log(result.length);
resolve(result);
});
};
reader.readAsDataURL(file);
} else {
alert('Your browser does not support FileReader');
}
7.0.9
5 months ago
7.0.10
5 months ago
7.0.4
5 months ago
7.0.6
5 months ago
7.0.0
6 months ago
7.0.3
6 months ago
7.0.2
6 months ago
7.0.1
6 months ago
6.2.1
6 months ago
6.2.2
6 months ago
6.1.0
7 months ago
6.0.1
7 months ago
6.1.1
7 months ago
6.0.2
7 months ago
6.0.0
9 months ago
5.0.1
10 months ago
5.0.0
10 months ago
4.1.0
1 year ago
4.0.3
1 year ago
4.0.1
1 year ago
4.0.0
1 year ago
3.0.11
1 year ago
3.0.10
1 year ago
3.0.8
1 year ago
3.0.9
1 year ago
3.0.7
1 year ago
3.0.4
1 year ago
3.0.3
1 year ago
3.0.6
1 year ago
3.0.5
1 year ago
3.0.2
1 year ago
3.0.1
1 year ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago