img-to-background (457B)
1 #!/usr/bin/env bash 2 # set the aspect ratio 3 # 16:10 == 1440x900 4 aspect_ratio="16:9" 5 6 if ! command -v convert &>/dev/null; then 7 echo "convert not installed." >&2 8 exit 1 9 fi 10 die() { 11 echo "$1" >&2 12 exit 1 13 } 14 15 [ $# -eq 1 ] || die "Filename argument needed." 16 [ -e "$1" ] || die "$1 does not exist." 17 [ -f "$1" ] || die "$1 is not a file." 18 newname="${1/#/siz-}" 19 convert "$1" -resize "$aspect_ratio" "$newname" 20 printf "Resized image written to %s\n" "$newname"