Skip to content

Instantly share code, notes, and snippets.

@cesarkohl
Last active January 15, 2021 11:57
Show Gist options
  • Save cesarkohl/26e918cb73b747534927683cb29a0722 to your computer and use it in GitHub Desktop.
Save cesarkohl/26e918cb73b747534927683cb29a0722 to your computer and use it in GitHub Desktop.
Sketch to Bitmap
################################################################################
################################################################################
# Main program #
################################################################################
################################################################################
Main()
{
echo Duplicating ${1}...
cp ${1} sketch.zip
echo Done.
echo Unzipping sketch.zip...
mkdir sketch-unzipped
tar xvf sketch.zip -C sketch-unzipped
echo Done.
echo Moving pngs...
mkdir pngs
mv sketch-unzipped/images/* pngs
echo Done.
echo Remove sketch-unzipped directory...
rm -R sketch-unzipped
echo Done.
echo Converting PNGs to JPGs
cd pngs
mkdir jpgs
sips -s format jpeg *.* --out jpgs
mv jpgs ../
cd ..
echo Done.
echo Removing sketch.zip file...
rm sketch.zip
echo Done.
echo Check out the jpgs and pngs directories!
}
################################################################################
# Help #
################################################################################
Help()
{
echo " __ _ _ _ _____ ___ _ _ "
echo "/ _\ | _____| |_ ___| |__/__ \___ / __(_) |_ _ __ ___ __ _ _ __ "
echo "\ \| |/ / _ \ __/ __| '_ \ / /\/ _ \ /__\// | __| '_ _ \ / _ | '_ \ "
echo "_\ \ < __/ || (__| | | / / | (_) / \/ \ | |_| | | | | | (_| | |_) |"
echo "\__/_|\_\___|\__\___|_| |_\/ \___/\_____/_|\__|_| |_| |_|\__,_| .__/ "
echo " |_| by BSA"
echo SketchToBitmap version 0.1 2021-01-13 19:24:00
echo
echo "Exports all bitmaps in a .sketch file converting them to pngs and jpgs."
echo
echo "Syntax: sketchToBitmap [-h|-f]"
echo
echo "Options:"
echo "-f Sets the sketch file to be exported."
echo "-h Display this help message."
echo
}
################################################################################
# Process the input options. Add options as needed. #
################################################################################
# Get the options
while getopts ":hf:" option; do
case $option in
h)
Help
;;
f)
if [ ! -z ${OPTARG} ]; then
Main ${OPTARG}
else
Help
fi
;;
esac
done
if [ $OPTIND -eq 1 ]; then
Help;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment