image-encode

Decode image data into any format: gif, jpeg, png, tiff or bmp

MIT 9 个版本
安装
npm install image-encode
yarn add image-encode
pnpm add image-encode
bun add image-encode
README

image-encode unstable Build Status

Encode image data to a container: PNG, GIF, BMP, JPEG or TIFF. Uses set of encoders in node and Canvas2D in browser.

Usage

npm install image-encode

let encode = require('image-encode')

// create a file with chess pattern
fs.writeFileSync(
	'out.png',
	Buffer.from(encode([0,0,0,255, 255,255,255,255, 255,255,255,255, 0,0,0,255], [2, 2], 'png'))
)

API

let data = encode(pixels, shape?, format|options?)

Takes input pixels Array/TypedArray/ArrayBuffer/Buffer/ImageData, returns an ArrayBuffer with encoded data in target format, one of png, gif, tif, bmp, jpg.

options can provide:

  • format or type, if not specified as a separate argument.
  • shape or width/height, if not defined by pixels or as a separate argument.
  • quality for JPG encoder.
  • colors for palette size in GIF encoder.
  • any other meta fields for encoders.

See also

© 2018 Dmitry Yv. MIT License.

版本列表
1.3.1 2021-01-15
1.3.0 2018-12-15
1.2.5 2018-11-14
1.2.4 2018-11-13
1.2.3 2018-11-13
1.2.2 2018-11-12
1.2.1 2018-11-12
1.2.0 2018-11-12
1.1.1 2018-11-12