Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 30 lines (19 sloc) 577 Bytes
#!/usr/bin/env bash
# imgresize: scale an image by a given percentage
set -eo pipefail
function help {
echo "Usage: imgresize <input> [scale%] [output]"
echo "Example: imgresize foo.jpg 50 half_foo.jpg"
exit
}
function installed {
cmd=$(command -v "${1}")
[[ -n "${cmd}" ]] && [[ -f "${cmd}" ]]
return ${?}
}
installed convert || { >&2 echo "Missing convert."; exit 1; }
input="${1}"
[[ -f "${input}" ]] || help
scale="${2:-50}"
output="${3:-$(dirname "${input}")/${scale}_$(basename "${input}")}"
convert "${input}" -resize "${scale}%" "${output}"
You can’t perform that action at this time.