image-rotation
Version:
Help the image complete compression and support rotation operations at any angle.
61 lines (58 loc) • 1.64 kB
Markdown
This module can help the image complete compression and support rotation operations at any angle.
```bash
yarn add image-rotation
```
```js
let imageRotate
import ImageRotation from 'image-rotation'
imageRotate = new ImageRotation('your html file data', options)
imageRotate.generate('rotate angle', downloadType) //
```
key | desc | type | defalut
----|------|----|----
file(required)| input[type=file] data |File or base64| null
options| options |object|{}
key | desc | type | defalut
----|------|----|----
maxLength| The maximum edge size |number| null
quality|compression quality|number|0.92
background|background|string|null
isDrawPngBg| whether to draw background for image/png | boolean | false
```js
import ImageRotation from 'image-rotation'
const imageRotate = new ImageRotation('your html file data', {
maxLength: 2000,
quality: 0.8,
background: "#fff",
isDrawPngBg: true
})
```
key | desc | type | defalut
----|------|----|----
rotate| rotation angle |Number| 0
downloadType| image type |string|image/jpeg
```js
const imageRotate = new ImageRotation('your html file data')
imageRotate.generate(45, 'image/png').then(res=> {
// base64
}).catch()
```
key | desc | type |
----|------|----
dataURI(required)| base64 file |string|
```js
const imageRotate = new ImageRotation('your html file data')
imageRotate.generate(0, 'image/png').then(res=> {
// base64
const blob = imageRotate.toBlob(res)
// blob
})
```