Advertisement
wyatt8740

i hate webp

May 15th, 2024
825
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.79 KB | None | 0 0
  1. #!/usr/bin/env sh
  2.  
  3. webfuck() {
  4.   DESTBASENAME="$(echo "$1" | sed 's!^.*/!!g;s!\.[Ww][Ee][Bb][Pp]$!!')"
  5.   wget -O "$DESTBASENAME"'.webp' "$1"
  6.   convert "$DESTBASENAME"'.webp' "$DESTBASENAME"'.png'
  7.   if [ "$?" -eq 0 ] && [ -e "$DESTBASENAME"'.png' ]; then
  8.     rm "$DESTBASENAME"'.webp'
  9.   else
  10.     1>&2 echo 'Error on: '"$1"
  11.   fi
  12. }
  13.  
  14. filefuck() {
  15.   DESTBASENAME="$(echo "$1" | sed 's!\.[Ww][Ee][Bb][Pp]$!!')"
  16.   if [ -e "$1" ]; then
  17.     convert "$1" "$DESTBASENAME"'.png'
  18.     if [ "$?" -eq 0 ] && [ -e "$DESTBASENAME"'.png' ]; then
  19.       rm "$1"
  20.       return 0
  21.     fi
  22.   fi
  23.   1>&2 echo 'Error on: '"$1"
  24. }
  25.  
  26. while [ "$#" -gt 0 ]; do
  27.  case "$1" in
  28.    'http://'*)
  29.      webfuck "$1"
  30.      ;;
  31.    'https://'*)
  32.      webfuck "$1"
  33.      ;;
  34.    *)
  35.      filefuck "$1"
  36.      ;;
  37.  esac
  38.  shift 1
  39. done
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement