Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including ndconvert with all npm packages installed. Try it out:

ndconvert lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

// require("ndconvert/[??]")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

ndconvert v0.1.1

Convert an image to an ndarray json file

ndconvert

A CLI tool for converting images (PNG) to ndarray json files.

Basically it is Mikola Lysenko's script copied and turned into a binary to run anywhere.

example

You have an image ./terrain.png. Convert it with ndconvert terrain.png > terrain.json. Then in your module use it with:

var decodeBase64 = require('base64-js').toByteArray
var ndarray = require('ndarray')

var terrain = require('./terrain.json')
var texture = ndarray(
  new Uint8Array(decodeBase64(terrain.data)),
  terrain.shape,
  terrain.stride,
  terrain.offset
)

install

With npm do:

npm install ndconvert -g

release history

  • 0.1.1 - fix issues with shape and stride
  • 0.1.0 - initial release
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free