#!/bin/bash

if [ $# != 1 ]; then
	echo "please input picture type.(ex.png)"
	exit 0
fi

echo "converting $1 to pdf file...."

mkdir .temp_mogrify
cp *.$1 .temp_mogrify/
cd .temp_mogrify
mogrify -resize 600 -format ps *.$1
aho=`ls | grep ps | paste -s | expand -t 1`
gs -q -sDEVICE=pswrite -dNOPAUSE -dBATCH -sOutputFile=output.ps $aho
ps2pdf output.ps ../output.pdf
cd ..
rm -rf .temp_mogrify
unset aho

echo "done. output 'output.pdf'."
