1.0.6 • Published 3 years ago

image-rotation v1.0.6

Weekly downloads
13
License
MIT
Repository
github
Last release
3 years ago

image-rotation

This module can help the image complete compression and support rotation operations at any angle.

Installation

  yarn add image-rotation

Usage

let imageRotate
import ImageRotation from 'image-rotation'
imageRotate = new ImageRotation('your html file data', options)
imageRotate.generate('rotate angle', downloadType) // 

APIs

new ImageRotation

keydesctypedefalut
file(required)inputtype=file dataFile or base64null
optionsoptionsobject{}

options(object)

keydesctypedefalut
maxLengthThe maximum edge sizenumbernull
qualitycompression qualitynumber0.92
backgroundbackgroundstringnull
isDrawPngBgwhether to draw background for image/pngbooleanfalse
import ImageRotation from 'image-rotation'
const imageRotate = new ImageRotation('your html file data', {
  maxLength: 2000,
  quality: 0.8,
  background: "#fff",
  isDrawPngBg: true
})

generate(rotate?: number, downloadType?: DownloadType): Promise

keydesctypedefalut
rotaterotation angleNumber0
downloadTypeimage typestringimage/jpeg
const imageRotate = new ImageRotation('your html file data')
imageRotate.generate(45, 'image/png').then(res=> {
  // base64
}).catch()

toBlob(dataURI: string): Blob

keydesctype
dataURI(required)base64 filestring
const imageRotate = new ImageRotation('your html file data')
imageRotate.generate(0, 'image/png').then(res=> {
  // base64
  const blob = imageRotate.toBlob(res)
  // blob
})