#!/bin/sh
inputfile="$1"
if [ -z "$inputfile" ]
then
    echo 'Usage: cut_skybox.sh INPUTFILENAME' >&2
    exit 1
fi

convert -extract 512x512+0+512 "$inputfile" "$(basename "$(basename "$inputfile" .png)" .jpg)_nx.jpg"
convert -extract 512x512+512+512 "$inputfile" "$(basename "$(basename "$inputfile" .png)" .jpg)_pz.jpg"
convert -extract 512x512+1024+512 "$inputfile" "$(basename "$(basename "$inputfile" .png)" .jpg)_px.jpg"
convert -extract 512x512+1536+512 "$inputfile" "$(basename "$(basename "$inputfile" .png)" .jpg)_nz.jpg"

convert -extract 512x512+512+0 "$inputfile" "$(basename "$(basename "$inputfile" .png)" .jpg)_py.jpg"
convert -extract 512x512+512+1024 "$inputfile" "$(basename "$(basename "$inputfile" .png)" .jpg)_ny.jpg"
