# tiled-image-tools

> A library to encode and decode Nintendo tiled images.

Latest version **1.1.2** (published 2023-03-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install tiled-image-tools
pnpm add tiled-image-tools
yarn add tiled-image-tools
bun add tiled-image-tools
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2023-03-31 |
| First published | 2017-08-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | DanTheMan827 |
| Maintainers | dantheman827 |

## Links

- npm: https://www.npmjs.com/package/tiled-image-tools
- Repository: https://github.com/DanTheMan827/node-tiled-image-tools
- Homepage: https://github.com/DanTheMan827/node-tiled-image-tools/
- Issues: https://github.com/DanTheMan827/node-tiled-image-tools/issues
- npm.io page: https://npm.io/package/tiled-image-tools

## Recent versions

- 1.1.2 (latest) — 2023-03-31
- 1.1.1 — 2017-08-19
- 1.1.0 — 2017-08-19
- 1.0.2 — 2017-08-06
- 1.0.1 — 2017-08-06

## README

# Tiled Image Tools
This is a promise-based library for encoding and decoding tiled images.

## Options
|Option        |Description|
|--------------|-----------|
|**Data**      |RGBA encoded data buffer|
|**Width**     |The image width, if encoding, you can specify a smaller width to crop to|
|**Height**    |The image height, if encoding, you can specify a smaller height to crop to|
|**cropWidth** |**Used when decoding**<br />The width to crop the output image to.
|**cropHeight**|**Used when decoding**<br /> The height to crop the output image to.
|**type**      |The encoding type, allowed values are:<br><br>a8<br>rgb888<br>rgb565<br>bgr888<br>bgr565|

## Encoding
This example will read a PNG using the pngjs library and encode the image data.
```javascript
var fs = require('fs')
var tileTools = require('tiled-image-tools')
var PNG = require('pngjs').PNG

fs.createReadStream('./MyImage.png')
  .pipe(new PNG({}))
  .on('parsed', function () {
    tileUtils.convertToTiled({
      'data': this.data,     // Raw RGBA data from pngjs
      'width': this.width,   // The image width, you can also specify a smaller size if you want to crop
      'height': this.height, // The image height, you can also specify a smaller size if you want to crop
      'type': 'rgb565'       // We will encode to rgb565
    }).then(function (encoded) {
      /*
        encoded will be an object with the following keys:
        
        data: A buffer with the encoded data
        width: The encoded image width
        height: The encoded image height
        type: The encoding type
      */
    }
  })
```

## Decoding
This example will take an RGB565 encoded image and decode it to RGBA
```javascript
var fs = require('fs')
var tileTools = require('tiled-image-tools')

fs.readFile('./RGB565Image.bin', function (data) {
  tileUtils.convertFromTiled({
    'data': data,    // The raw RGB565 data
    'width': 48,     // This must be provided when decoding
    'height': 48,    // This must be provided when decoding
    'type': 'rgb565' // We are decoding from rgb565
  }).then(function (decoded) {
    /*
      decoded will be an object with the following keys.
      
      data: A buffer with the decoded RGBA values
      width: The image width
      height: The image height
      type: the encoding type used to decode the image.
    */
  })
}
```

# Credits
Based on code by Marc Robledo<br>
http://usuaris.tinet.cat/mark/smdh_creator/

---
_Source: https://npm.io/package/tiled-image-tools · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
