#!/bin/bash
# display exif information for the image path passed... "$1"
#
# test if a filename was passed, bail if not
if [ "$#" == "0" ]; then
	yad --title "No Image File..." --button="gtk-ok:0" --center --window-icon="/usr/share/pixmaps/error.png" --text="    No image name/path was provided    \n     the exif display needs a filename to work with :-)     "
    exit 1
fi

# test if exiftool (needed to gather the image info) is present, bail if not
hash exiftool 2>/dev/null || { yad --title "Missing Required Tool" --button="gtk-ok:0" --center --window-icon="/usr/share/pixmaps/error.png" --text="    perl Exiftool is missing    \n    It is required to display image EXIF information.   "; exit 1; }

# test if the passed filename is an image:
isImage=`file -i "$1" | grep "image/"`
if [ -z "$isImage" ]
then
yad --title "Not an Image" --button="gtk-ok:0" --center --window-icon="/usr/share/pixmaps/error.png" --text="   The filename passed:  \n   \"$1\"  \n   does not appear to be an image file.  "
  exit 0
fi

# since it seems to be an image, use exiftool and yad to display image information
exiftool -a -G1 -s "$1" | yad --text-info --window-icon="/usr/share/pixmaps/image-x-generic.png" --title "Image Information" --center --width 640 --height 500
exit 0
