node package manager


rgb-pack experimental

Packs integer values from a 2D ndarray into an RGB one for storing as compressed images.

Works particularly well for storing heightmaps with more precision than a single channel can offer - instead of a dynamic range of 256 values, you get 16,777,216. You could combine this pretty easily with save-pixels and get-pixels for good results.



require('rgb-pack').pack(map[, image])

Packs a 2D ndarray map into a 3D image ndarray. You could then use save-pixels to store this result as a PNG image.

If you don't supply an image, one will be created for you.

Note that the data in map are expected to be integer values between 0 and 16,777,216.

require('rgb-pack').unpack(image[, map])

Unpacks a previously packed image ndarray into a 2D map.

If you don't supply a map, one will be created for you.


MIT. See for details.