Using homebrew, do the following in the Terminal.
brew update
brew upgrade
brew install ghostscript
brew cleanup
The ghostscript 9.26_1 executable will be installed in /usr/local/bin as gs.
Life is too short to be dealing with internal Automator action mischief. I am changing the solution to a three-action Automator solution. Once you have Ghostscript 9.26.1 installed, edit your Automator application. You do this by launching Automator, cancelling its file dialog, and choosing Open Recent… and your application name.
Keep only these three actions:
- Ask for Finder Items
- Filter Finder Items
- Run Shell Script
Clear the contents from the Run Shell Script action, and copy/paste the following into it:
DPI=300
PAGEMAX=10
OUTFOLDER="$HOME/Desktop/PDF/"
for f in "$@"
do
page_cnt=$(mdls -name kMDItemNumberOfPages "$f" | awk '{print $NF}')
# force ten page limit if higher page count
[[ page_cnt -ge PAGEMAX ]] && page_cnt=$PAGEMAX
# simultaneously strip path and extension
shopt -s extglob
BASE="${f//+(*\/|.*)}"
shopt -u extglob
# The intents set to zero is perceptual rendering
/usr/local/bin/gs -q -dSAFER -sDEVICE=jpeg -r$DPI -dTextAlphaBits=4 -dGraphicsAlphaBits=4 \
-dLastPage=$page_cnt -dTextIntent=0 -dRenderIntent=0 -dImageIntent=0 \
-dFIXEDMEDIA -dPDFFitPage -o $OUTFOLDER${BASE}_%02d.jpeg "$f"
done
The script will limit the page count to 10 if it is greater in the PDF, and its does sequential numbers of imaged pages correctly.