#!/bin/bash
# This file is distributed under the GPL license.
# Requirements: imagemagick, wine, PalmRI.exe
# Creates a SlideShow.prc file with several images to be viewed in Slider for palm.
# Usage: ./slider-converter

		rm -r ./images > /dev/null 2>&1
		mkdir -p ./images/processed > /dev/null 2>&1
		cp ./SliderDB_template.prc ./SlideShow.prc
		
		clear
		echo
		echo "----------------------------------------------------"
		echo
		echo "Slider SlideShow generator."
		echo
		echo "----------------------------------------------------"
		echo
		echo "Place all image files to be converted in the folder 'images' and press RETURN."
		read junk
		
		cd ./images

		shopt -s nullglob
		TBMP_NR=1000

		# Change extensions as needed
		for i in *.{jpg,png,gif,bmp}

		do
		
		fullpath="$i"
		extension="${fullpath##*.}"
		filename="${fullpath%.*}"
		
		# Color Pictures
		convert -resize 160x140! -colors 256 -depth 8 "$i" ./processed/"$filename"_160.bmp 

		# Monochrome Pictures
		#convert -resize 160x140! -depth 8 -colorspace Gray "$i" ./processed/"$filename"_160.bmp 

		wine ./../PalmRI.exe ./processed/"$filename"_160.bmp:8 ./../SlideShow.prc Tbmp $TBMP_NR

		TBMP_NR=$[TBMP_NR + 1]

		done

		echo
		echo
		echo "SlideShow.prc generated."
		echo
		echo "Done."

