0.1.5 • Published 4 years ago
pai-converter v0.1.5
Pixel Art Image Converter
Pixel Art Image is a image format created just as a test, and because I had nothing better to do. Fun fact: this was a shower thought.
It is horribly implemented, but takes a smaller file size than PNG for most images it was designed for (Pixel Art)
Size Comparison
| Name | Size | PAI Size | PNG Size |
|---|---|---|---|
| Bassalt | 16x16 | 712 bytes | 3370 bytes |
| Block | 16x16 | 50 bytes | 131 bytes |
| Smiley | 16x16 | 219 bytes | 410 bytes |
| Brick | 32x32 | 78 bytes | 184 bytes |
| Tree | 64x64 | 355 bytes | 740 bytes |
Installation
# Using NPM:
npm i pai-converter
# Using Yarn:
yarn add pai-converterGetting Started
Import the package:
import { toPaiImage, paiToImage } from 'pai-converter';Now you can save convert images to and from PAI and PNG!
Convert to PAI from PNG:
import { toPaiImage } from 'pai-converter';
toPaiImage('smiley.png', {
seperators: { pixel: '@', line: '&', size: ':', multiLine: 'x' },
quality: 11,
writeToFile: true,
fileName: 'smiley.pai',
});Convert to PNG from PAI:
import { paiToImage } from 'pai-converter';
paiToImage('smiley.pai', 'smiley-converted.png');Closing Note
- I'm not going to document the rest of this unless there is actually a want, but it is created in Typescript and therefor has types and interfaces :)