# create magick shell command to convert the first page of PDF file into image format # Usage: convert_magic.sh # convert_magic.sh input.pdf png output.png # check if the PDF file exists if [ ! -f $1 ]; then echo "File $1 does not exist" exit 1 fi # check if the image format is specified if [ -z $2 ]; then echo "Image format is not specified" exit 1 fi # check if the image format is supported if [ $2 != "png" ] && [ $2 != "jpg" ] && [ $2 != "gif" ]; then echo "Image format $2 is not supported" exit 1 fi # check if desired output not specified if [ -z $3 ]; then echo "Output name not specified" exit 1 fi # convert the first page of PDF file into image format magick convert -density 300 -quality 100 $1\[0\] $2:$3