guess-image-layout
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

guess-image-layout

Guess the Layout of Image Pixels. Returns layout in xdim layout syntax.

install

npm install guess-image-layout

basic usage

import guessImageLayout from "guess-image-layout";

const rgba = [123, 234, 42, 255, 124, 42, 42, 255, ...];
guessImageLayout({ data: rgba, bands: 4, height: 768  });
// { layout: "[row,column,band]", bands: 4, height: 768, width: 1024 }

const bands = [
  [123, 124, ...], // red band
  [234, 42, ...], // green band
  [42, 42, ...], // blue band
  [255, 255, ...] // alpha band
];
guessImageLayout({ data: bands });
// { layout: "[band][row,column]", bands: 4, height: undefined, width: undefined }

advanced usage

If you already know the array of layout of the data, you can pass that in and it will calculate what it can.

import guessImageLayout from "guess-image-layout";

const rgba = [123, 234, 42, 255, 124, 42, 42, 255, ...];

guessImageLayout({ data: rgba, layout: "[band][row,column]" })
// { "bands": 4, "layout": "[band][row,column]", height: undefined, width: undefined }

Dependencies (1)

Dev Dependencies (2)

Package Sidebar

Install

npm i guess-image-layout

Weekly Downloads

4,584

Version

0.1.0

License

CC0-1.0

Unpacked Size

12.5 kB

Total Files

5

Last publish

Collaborators

  • danieljdufour