Skip to content

Instantly share code, notes, and snippets.

@iskolbin
Created March 28, 2018 11:25
Show Gist options
  • Save iskolbin/2c9c36a7ce2a043eb4b7fb1ee4dfaf42 to your computer and use it in GitHub Desktop.
Save iskolbin/2c9c36a7ce2a043eb4b7fb1ee4dfaf42 to your computer and use it in GitHub Desktop.
Texture packer unpacker (jq and imagmagick (convert) required)
#!/bin/bash
if [ -z $1 ]; then
echo "Atlas cropper 2018 v666 by Ilya Kolbin"
echo "Usage: ./crop_atlas.sh <atlas.json> <output_path>"
echo "Atlas is json like {"frames":{<filename>:<frame>:{x,y,w,h}}}"
fi
IMG=$(cat $1 | jq -j ".meta.image")
cat $1 | jq -j --unbuffered ".frames|to_entries|.[]|\"convert $IMG -crop \",.value.frame.w,\"x\",.value.frame.h,\"+\",.value.frame.x,\"+\",.value.frame.y,\" \",.key,\"\n\"" | bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment