#!/bin/bash
echo "This will convert all jpg, png & bmp images in the current directory to correct print format"
read -p "Are you sure(y/n)? " reply
if [ $reply != y ]; then
    exit 1
fi
echo " "

# 11.04 Natty version
convert --version | grep -q "6.6.2-6"
if [ $? -eq 0 ]; then
	option=""
fi
# 12.04 LTS version
convert --version | grep -q "6.6.9-7"
if [ $? -eq 0 ]; then
	option="-negate"
fi

for i in *.jpg *.JPG *.bmp *.BMP *.png *.PNG *.jpeg *.JPEG
do
	if [ -a "$i" ]; then
		name=`echo "$i" | cut -d'.' -f1`
		new_file=$HOME/.pcscale/printer/images/$name.png
		convert -resize 448x-1\> -monochrome $option -transparent white "$i" "$new_file"
		echo " > File $i converted to $new_file." 
	fi
done
