Skip to content

Instantly share code, notes, and snippets.

@timf
Created June 20, 2013 01:55
Show Gist options
  • Save timf/5819731 to your computer and use it in GitHub Desktop.
Save timf/5819731 to your computer and use it in GitHub Desktop.
Pass an X.tiff file to this --> X.png
#!/bin/bash
echoerr() { echo "$@" 1>&2; }
if [ "X" == "X$1" ]; then
echoerr "error: requires argument: path to .tiff file"
exit 1
fi
exe=`which sips`
if [ "X" == "X$exe" ]; then
echoerr "error: cannot find sips program"
exit 1
fi
outputfile=`echo "$1" | sed 's/\.tiff$/\.png/'`
if [ "$1" == "$outputfile" ]; then
echoerr "error: file must end in .tiff"
exit 1
fi
if [ -f $outputfile ]; then
echoerr "error: already exists: $outputfile"
exit 1
fi
CMD="$exe -s format png $1 --out $outputfile"
echo "Running: $CMD"
exec $CMD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment