#!/bin/bash
if [ ! -f "$1" ]; then
    echo "File $1 does not exist. Aborting..."
    exit
fi

suffix=".webp"
filename=${1%"$suffix"}
outfile="$filename.png"

if [ -f "$outfile" ]; then
    echo "File $outfile already exists. Aborting..."
    notify-send --app-name=webpkiller "File $outfile already exists. Aborting..."
    exit
fi

magick $1 $outfile
rm -rf $1

xdg-open $outfile
