#!/bin/bash
# Script: convert_to_bmp.sh
if [[ -f $1 ]]; then
  IMGFILE=$1
  BMPFILE=${IMGFILE%.*}.bmp
  OPTIONS="-resize 320x240 -background black -compose Copy -gravity center -extent 320x240 -depth 24 -alpha remove -alpha off -compress none BMP3:"
  convert ${IMGFILE} ${OPTIONS}${BMPFILE}
else
  echo "Cannot read file"
fi

RESULT=$(identify ${BMP} | cut -d ' ' -f 2)

if [[ ${RESULT}='BMP' ]]; then
  echo "Conversion OK: ${BMPFILE}"
else
  echo "Something went awry: ${RESULT}"
fi
