#!/bin/bash
#file="IMG_0327.PNG"
temp="temp.png"
rm -f ${temp}
file=$1
exiftool -list $file  | grep "Date Created  " | cut -b 35-54 > txt 
more txt
test=`more txt`
#echo "Before replacement : $test"
test1=${test/:/-}
echo "After replacement1 : ${test1}"
test2=${test1/:/-}
echo "After replacement2 : ${test2}"
#date --date="`echo ${test2}`" +%s 
date --date="`echo ${test2}`" +%s > isecondst 
# shift 2 hours for GMT
diff=7200
iseconds1=`more isecondst`
echo "Test 1 iseconds1="$iseconds1
echo "Test 1 diff="$diff
iseconds=$((iseconds1+diff))
echo "Test 2 iseconds="$iseconds
filenew=$iseconds.jpg
echo "filenew=$filenew"
#convert -resize 512x384 ${file} ${filenew}
#convert -resize 768x576 ${file} ${filenew}
convert -resize 800x600 ${file} ${temp}
convert -extract 800x575+0+25 ${temp} ${filenew}
#rm -f ${temp}
exit
