#!/bin/bash
for i in $@;
do
	if [ -f "${i}" ]; then
		gs \
			-sDEVICE=pdfwrite \
			-dCompatibilityLevel=1.4 \
			-dPDFSETTINGS=/default \
			-dNOPAUSE -dQUIET -dBATCH \
			-dColorConverstionStrategy=/sRGB \
			-dDownsampleColorImages=true \
			-dDownsampleGrayImages=true \
			-dDownsampleMonoImages=true \
			-dOptimize=true \
			-sOutputFile="${i}" \
			"${i}_small.pdf"
	else
		echo "${i} is not a valid file."
	fi
done
