#!/bin/bash

if [ $# != 2 ]; then
	echo "usage:./mogrify2pdf [picture type] [output size(defalt=600)]"
	exit 0
fi

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

mkdir .temp_mogrify
cp *.$1 .temp_mogrify/
cd .temp_mogrify
mogrify -resize $2 -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'."
