tiledpalettequantcli
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "tiledpalettequantcli", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A nodejs cli version of https://github.com/rilden/tiledpalettequant (https://rilden.github.io/tiledpalettequant/) allowing for conversion of images to quantized bitmap files, with optional dithering", | ||
@@ -5,0 +5,0 @@ "main": "script.js", |
# TiledPaletteQuantCLI | ||
A nodejs cli version of https://github.com/rilden/tiledpalettequant (https://rilden.github.io/tiledpalettequant/) allowing for conversion of images to quantized bitmap files, with optional dithering. | ||
A NodeJS command line interface port of rilden's fantastic tile palette quantization / dithering tool https://rilden.github.io/tiledpalettequant/ (https://github.com/rilden/tiledpalettequant)/ | ||
An additional feature is the ability to vertically split the quantized image. This can be used to quantize multiple images using a shared set of palettes. | ||
An additional feature added is the ability to vertically split the quantized image. This can be used to quantize multiple images using a shared set of palettes. | ||
@@ -11,5 +11,5 @@ Note that this has only been tested in WSL so your milage may vary running on other platforms (anything with a terminal that can run NodeJS should work though). | ||
With a recent version of NodeJS installed, run one of the following: | ||
- `npm -i tiledpalettequantcli` | ||
- `npm install tiledpalettequantcli` | ||
- `npx tiledpalettequantcli` | ||
- `npm -i tiledpalettequantcli -g` (to install globally) | ||
- `npm install tiledpalettequantcli -g` (to install globally) | ||
@@ -25,2 +25,3 @@ # Usage | ||
| -o | --output [prefix] | Output name prefix (default is the current directory name) | | ||
| -si | --startIndex [si] | Start index for output names (default is no suffix if not needed, 0 if using --vsplit) | | ||
| -tw | --tileWidth [width] | Tile width px (default: 8) | | ||
@@ -50,3 +51,6 @@ | -th | --tileHeight [height] | Tile height px (default: 8) | | ||
`magick *.jpg -background 'rgba(0,0,0,0)' -resize '240' -extent 256x256 -append png:- | npx tiledpalettequantcli -output sharedPaletteExample -vsplit 256 -d Slow -p 5` | ||
Using an external tool to resize and quantize multiple source images at once: | ||
`magick *.jpg -background 'rgba(0,0,0,0)' -resize '240' -gravity Center -extent 256x256 -append png:- | npx tiledpalettequantcli -output sharedPaletteExample -vsplit 256 -d Slow -p 5` | ||
@@ -58,2 +58,7 @@ #! /usr/bin/env node | ||
.option( | ||
'-si, --startIndex [si]', | ||
'Start index for output names (default is no suffix if not needed, 0 if using --vsplit)', | ||
myParseOptionalInt | ||
) | ||
.option( | ||
'-tw, --tileWidth [width]', | ||
@@ -138,2 +143,3 @@ 'Tile width px', | ||
const vsplit = opts.vsplit; | ||
const startIndex = opts.startIndex; | ||
@@ -221,2 +227,3 @@ const readable = opts.file ? fs.createReadStream(opts.file) : process.stdin; | ||
const pixelsPerSlice = imageData.width * vsplit; | ||
const suffixStartIndex = startIndex ?? 0; | ||
if (verticalSliceCount > 1) { | ||
@@ -226,3 +233,3 @@ for (let i = 0; i < verticalSliceCount; i++) { | ||
let bmpResult = bmpToDataURL(imageData.width, vsplit, imageData.paletteData, slicedData); | ||
saveImage(bmpResult, i); | ||
saveImage(bmpResult, suffixStartIndex + i); | ||
} | ||
@@ -232,5 +239,5 @@ return; | ||
} | ||
const suffix = startIndex === null ? '' : startIndex | ||
const bmpResult = bmpToDataURL(imageData.width, imageData.height, imageData.paletteData, imageData.colorIndexes); | ||
saveImage(bmpResult); | ||
saveImage(bmpResult, suffix); | ||
} | ||
@@ -237,0 +244,0 @@ |
60730
1478
54