Skip to content

Instantly share code, notes, and snippets.

@FradSer
Last active February 25, 2016 06:53
Show Gist options
  • Save FradSer/1a8170100a654626a08d to your computer and use it in GitHub Desktop.
Save FradSer/1a8170100a654626a08d to your computer and use it in GitHub Desktop.
# 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