# image-compress-browser

> compress image on browser

Latest version **1.0.4** (published 2019-06-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install image-compress-browser
pnpm add image-compress-browser
yarn add image-compress-browser
bun add image-compress-browser
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2019-06-25 |
| First published | 2017-04-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.8 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | kaivean |
| Maintainers | kaivean |

## Links

- npm: https://www.npmjs.com/package/image-compress-browser
- Repository: https://github.com/kaivean/image-compress-browser
- Homepage: https://github.com/kaivean/image-compress-browser#readme
- Issues: https://github.com/kaivean/image-compress-browser/issues
- npm.io page: https://npm.io/package/image-compress-browser

## Recent versions

- 1.0.4 (latest) — 2019-06-25
- 1.0.4-beta6 (beta6) — 2021-03-29
- 1.0.4-beta5 (beta5) — 2021-03-29
- 1.0.4-beta4 (beta4) — 2021-03-29
- 1.0.4-beta2 (beta2) — 2021-03-24
- 1.0.4-beta1 (beta1) — 2021-03-24
- 1.0.3-1 (alpha) — 2019-05-31
- 1.0.3 — 2019-05-07
- 1.0.2 — 2017-04-13
- 1.0.1 — 2017-04-13
- 1.0.0 — 2017-04-13

## README

compressImage
==========

compress image on browser


## Api
compressImage(file, callback)

### param: file
`File`, file comes generally from `<input type="file" />`

### param: callback
execute the callback after compressing image.
callback(newFile)

##### param: newFile
`File`, the file compressed

## Example

### Using require

```
var compressImage = require('image-compress-browser');
compressImage(file, function (newFile, isCompressed) {
    // isCompressed: -1失败，使用原文件；0未压缩； 1压缩成功
    console.log('file:', file.size, 'newFile', newFile.size, 'isCompressed', isCompressed);
});
```

### Using compressed file
```
<script src="./node_modules/image-compress-browser/dist/compressImage.js"></script>
<script>
compressImage(file, function (newFile, isCompressed) {
    // isCompressed: -1失败，使用原文件；0未压缩； 1压缩成功
    console.log('file:', file.size, 'newFile', newFile.size, 'isCompressed', isCompressed);
});
</script>
```

## ChangeLog
#### 2017.4.12
release v1

#### 2019.6.25
release v1.0.4 支持指定最大分辨率，压缩图片质量，生成图片是否是正方形，图片数据的类型（二进制 or base64），获取压缩结果（是否成功）

---
_Source: https://npm.io/package/image-compress-browser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
