This module can help the image complete compression and support rotation operations at any angle.
yarn add image-rotationlet 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 |
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 |
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 |
const imageRotate = new ImageRotation('your html file data')
imageRotate.generate(0, 'image/png').then(res=> {
// base64
const blob = imageRotate.toBlob(res)
// blob
})