#!/bin/sh
# This Bourne shell script converts Postscript and PDF documents to JPEG.
# Metadata is not converted to image comments, although it could be.

# This script is in the public domain.  marko.makela (at) iki.fi, Feb 23, 2006,
# with thanks to Axel Rose for a sample Ghostscript command line.

head -1 "$IMG_IN" | grep '^%\(!PS-Adobe\|PDF-\)' > /dev/null || exit 1

exec gs -dBATCH -dNOPAUSE \
-dUseCIEColor -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r72 \
-sDEVICE=jpeg -dFirstPage=1 -dLastPage=1 \
-sOutputFile="$IMG_OUT" "$IMG_IN" -c quit >/dev/null
