This script extracts all frames from a PNG spritesheet according to its JSON-file and puts them into the folder created next to it.
Usage: node unpack [filename.png[, filename.json[, output_foldername]]]
Assumes that spritesheet is a PNG-file and its JSON is a TexturePacker like (not rotated), i.e.
{"frames":
{
"games/smsh!/res/img/ui/buttons/left/down.png":
{
"frame": {"x":1305,"y":246,"w":38,"h":47}
},
"games/smsh!/res/img/ui/buttons/left/over.png":
{
"frame": {"x":1289,"y":303,"w":38,"h":47}
},
"games/smsh!/res/img/ui/buttons/left/up.png":
{
"frame": {"x":1329,"y":295,"w":38,"h":47}
}
}
}
or is array "frames" of [x,y,width,height] arrays, i.e.
{"frames": [
[860, 514, 96, 48],
[960, 608, 96, 48],
[960, 740, 32, 16]
]}
'fs-extra', 'path' and 'pngjs' packages required. Use 'npm install pngjs
', etc.
1.1.0 Rotated sprites are now supported (but not rotated back)