img-about
pkg.module supported
, which means that you can apply tree-shaking in you project
A module for image processing in browser, includes getting naturalSize, zooming, compressing... wrapped by Promise
You may need a Promise polyfill while use old IE browser( >= IE9 )
repository
https://github.com/livelybone/img-about.git
Demo
https://livelybone.github.io/tool/img-about/
Installation
npm i -S img-about
Global name
ImgAbout
Usage
import {getNaturalSize, imgCompress, canvasSupport, getSizeOfUrl } from 'img-about';
when you want to set this module as external while you are developing another module, you should import it like this:
import * as ImgAbout from 'img-about'
Use in html, see what your can use in CDN: unpkg
<-- use what you want -->
<script src="https://unpkg.com/img-about/lib/umd/<--module-->.js"></script>
Functions
getNaturalSize
(url: String|Image|File|FileList|Blob) => Promise<Object: {width, height}>
imgCompress
(imgFile: File|Blob, compressOptions: CompressOptions) => Promise<Blob|String>
var compressTypes = [
'scale',
'fixedWidth',
'fixedHeight',
'fixedSize',
]
var defaultOptions = {
compressType: compressTypes[0],
scale: 1,
imageSize: 0,
imageType: imgFile.type || 'image/png',
quality: .8,
toBlob: true,
}