Skip to content

Instantly share code, notes, and snippets.

@FradSer
Last active Feb 25, 2016
Embed
What would you like to do?
# 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