README
handy-img
handy img tool and API
Install
$ npm i -S handy-img
cli
just type himg
or handy-img
$ himg
himg <命令>
命令:
himg compress <file> compress file [aliases: c]
himg info <file> show info for file [aliases: i]
选项:
--version 显示版本号 [布尔]
--help 显示帮助信息 [布尔]
缺少 non-option 参数:传入了 0 个, 至少需要 1 个
API
const himg = require('handy-img')
-> metadata(input)Promise<Object>
- use
sharp
extract img metadata input
can beString filepath
orBuffer buf
-> decode(input)Promise<ImageDataLike>
- use
sharp
decode img input
can beString filepath
orBuffer buf
ImageDataLike
has signature
type ImageDataLike = {
data: Uint8Array
width: number
height: number
}
mozjpegEncode
function mozjpegEncode(
data: Uint8Array,
width: number,
height: number,
options: Object
): Promise<Buffer>
encode the ImageData to compressed jpeg buffer
mozjpegCompress
type Input = string | Buffer
function mozjpegCompress(input: Input, options: Object): Promise<Buffer>
use mozjpeg to compress file
Changelog
License
the MIT License http://magicdawn.mit-license.org