dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

removebg (538B)


      1 #!/bin/sh
      2 die() {
      3   echo "$1" >&2
      4   exit 1
      5 }
      6 
      7 # Preliminary checks
      8 command -v convert >/dev/null 2>&1 || die "imagemagick not found."
      9 [ $# -ge 2 ] || die "Usage: $0 input.ext output.ext"
     10 [ -f "$1" ] || die "File $1 not found."
     11 [ -f "$2" ] && {
     12   printf "File %s exists, overwrite? [y/N] " "$2"
     13   read -r conf; case "$conf" in
     14     Y*|y*) ;;
     15     *) exit 0 ;;
     16   esac
     17 }
     18 
     19 fuzz="${3:-15%}"
     20 convert -trim -transparent white -fuzz "$fuzz" "$1" "$2"
     21 printf "Saved as %s\nIf the result looks bad, pass a fuzz percentage as the last argument." "$2"