Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env sh
- webfuck() {
- DESTBASENAME="$(echo "$1" | sed 's!^.*/!!g;s!\.[Ww][Ee][Bb][Pp]$!!')"
- wget -O "$DESTBASENAME"'.webp' "$1"
- convert "$DESTBASENAME"'.webp' "$DESTBASENAME"'.png'
- if [ "$?" -eq 0 ] && [ -e "$DESTBASENAME"'.png' ]; then
- rm "$DESTBASENAME"'.webp'
- else
- 1>&2 echo 'Error on: '"$1"
- fi
- }
- filefuck() {
- DESTBASENAME="$(echo "$1" | sed 's!\.[Ww][Ee][Bb][Pp]$!!')"
- if [ -e "$1" ]; then
- convert "$1" "$DESTBASENAME"'.png'
- if [ "$?" -eq 0 ] && [ -e "$DESTBASENAME"'.png' ]; then
- rm "$1"
- return 0
- fi
- fi
- 1>&2 echo 'Error on: '"$1"
- }
- while [ "$#" -gt 0 ]; do
- case "$1" in
- 'http://'*)
- webfuck "$1"
- ;;
- 'https://'*)
- webfuck "$1"
- ;;
- *)
- filefuck "$1"
- ;;
- esac
- shift 1
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement