Created
July 20, 2018 05:55
-
-
Save jinuljt/5a8101032e3eac98281ac33bd58f69db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# require curl/wget/jq | |
TOKEN="<API key from https://tinypng.com/developers>" | |
if [ -z "$1" ]; then | |
echo "will create a shrink-<image_name> file" | |
echo "" | |
echo "usage:" | |
echo " tinypng <path/to/image.(png/jpg)>" | |
echo "" | |
echo "example:" | |
echo " tinypng ~/test.png" | |
exit 1 | |
fi | |
DIR=`dirname "$1"` | |
OUTPUT=shrink-`basename "$1"` | |
echo "upload $1 to tinypng" | |
URL=`curl --user api:$TOKEN --data-binary @$1 https://api.tinify.com/shrink|jq -r ".output.url"` | |
echo "download shrinked image $URL" | |
wget $URL -O "$DIR/$OUTPUT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment