#!/usr/bin/env zsh

png2jpg() {
  infile=$1
  outfile="${infile%.*}.jpg"

  mogrify -format jpg "$infile"

  if [ $? = 0 ]; then
    feh $outfile
    gum confirm "Remove original file?" --default=false --affirmative "Yes" --negative "No" && echo "removing";rm -rf $infile || echo "ok then."
  fi
}

jpg2png() {
  infile=$1
  outfile="${infile%.*}.png"

  mogrify -format png "$infile"

  if [ $? = 0 ]; then
    feh $outfile
    gum confirm "Remove original file?" --default=false --affirmative "Yes" --negative "No" && \
    echo "removing...";rm -rf $infile || echo "ok then."
  fi
}
