Created
January 4, 2019 09:55
-
-
Save cuixin/59a92f7cd16d6760496865cdfd38d02b to your computer and use it in GitHub Desktop.
Revisions
-
cuixin created this gist
Jan 4, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ #!/bin/bash function tinypng() { if [[ -z $APK_KEY ]]; then echo "API_KEY not defined"; return 1; fi if [[ -z $1 ]]; then echo "path is empty"; return 1; fi body=$(curl https://api.tinify.com/shrink \ --user api:$API_KEY \ --data-binary @$1) echo $body location=$(echo $body | jq '.output.url' | tr -d '"') if [[ -z $location ]]; then echo "download url is empty"; return 1; fi echo $location curl $location \ --user api:$API_KEY \ --output $1 } tinypng $@