Last active
February 25, 2016 06:53
-
-
Save FradSer/1a8170100a654626a08d 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
# Compress image with TinyJPG | |
function compress() { | |
if [ -n "${TinyJPG_API}" ]; then | |
for image in $*; do | |
local url=$(curl -i --user api:$TinyJPG_API --data-binary @"$image" https://api.tinify.com/shrink | grep Location: | awk '{split($0,a,": ");print a[2]}' | tr -d '\r'); | |
wget $url -O "$image"; | |
done | |
else | |
echo "TinyJPG_API is not defined! Please defined TinyJPG_API in ~/.path" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment