reducing the wxh of embedded media

Matthew Lenz <[email protected]> Fri, 9 Mar 2018 08:40:16 -0600
Newsgroups gmane.comp.printing.ghostscript.devel
Message-ID <CANpBAJvhZRcOzGGQwTXc6X2-DuAFHyr_-JETJvBCer_h1WmuGA@mail.gmail.com>
17 page document

$ pdfimages -list source.pdf
page   num  type   width height color comp bpc  enc interp  object ID x-ppi
y-ppi size ratio
--------------------------------------------------------------------------------------------
   2     0 image     200    47  rgb     3   8  image  no        10  0
93    93 2544B 9.0%
   3     1 image    3264  2448  rgb     3   8  jpeg   no        15  0
96    54  607K 2.6%
   4     2 image    3264  2448  rgb     3   8  jpeg   no        21  0
96    54  451K 1.9%
   5     3 image    3264  2448  rgb     3   8  jpeg   no        27  0
96    54  555K 2.4%
   6     4 image    3264  2448  rgb     3   8  jpeg   no        33  0
96    54  491K 2.1%
   7     5 image    3264  2448  rgb     3   8  jpeg   no        40  0
96    54  419K 1.8%
   8     6 image    3264  2448  rgb     3   8  jpeg   no        46  0
96    54  345K 1.5%
   9     7 image    3264  2448  rgb     3   8  jpeg   no        52  0
96    54  428K 1.8%
  10     8 image    3264  2448  rgb     3   8  jpeg   no        58  0
96    54  462K 2.0%
  11     9 image    3264  2448  rgb     3   8  jpeg   no        64  0
96    54  475K 2.0%
  12    10 image    3264  2448  rgb     3   8  jpeg   no        71  0
96    54  462K 2.0%
  13    11 image    3264  2448  rgb     3   8  jpeg   no        77  0
96    54  517K 2.2%
  14    12 image    3264  2448  rgb     3   8  jpeg   no        83  0
96    54  449K 1.9%
  15    13 image    3264  2448  rgb     3   8  jpeg   no        89  0
96    54  475K 2.0%
  16    14 image     802   237  rgb     3   8  image  no        98  0
 464   422 12.1K 2.2%

The embedded images on pages 3-15 are excessive in size for our needs and
result in larger than necessary pdf.

I'd like to reduce the height/width of the embedded images as well as
convert them to gray.

I've got the gray conversion working (-sProcessColorModel=DeviceGray
-sColorConversionStrategy=Gray) but I'm not having any luck resizing the
embedded images.  All the info I'm finding on reducing image size is with
regards to lowering the dpi using the various distiller presets.  I've been
messing with the -g (-dDEVICEWIDTH & -dDEVICEHEIGHT) parameter but getting
inconsistent (probably not inconsistent just not sure how to interpret the
results).

Right now my only thoughts are to identify the pages with large images and
no text (pdfinfo, pdffonts, pdfimages), extract the images (pdfimages) from
the document, resize them (imagemagick convert) and then re-render the pdf
using all the pages.

The hope is that ghostscript has some way to do this out of box.

-Matt