3

I have a large set PDF documents, many of which will be multiple pages.

I am using Ghostscript [GS] to generate a JPG thumbnail image for each PDF.

I only want one JPG per PDF, which should be an image of the first page only

It seems that GS allows me to do one of the following, only:

  1. create an image which contains ALL pages of the PDF, or
  2. create multiple images per PDF by including the characters "%d" within the output filename, where each image represents one page of the PDF

The problem with option 1 is that I only want page 1 The problem with option 2 is that I only want one file (multiple files will be generated if the PDF is multiple pages)

Given that option 2 is the closest solution to my requirements, I am writing a script to generate multiple JPGs per PDF, and then rename the first and delete the others, hence ending up with just the one file with the name that I want.

I cannot see an option in the GS help page, but can I avoid this slightly convoluted process and more easily instruct GS only to generate 1 JPG for page 1 of each PDF?

4
  • 1
    I do not know how to achieve what you want with ghostscript, however, if you are open to work with something else, pdfimage can certainly achieve what you are expecting : xpdfreader.com/pdfimages-man.html
    – MC68020
    Sep 14, 2020 at 16:43
  • 2
    Have a look at options -dFirstPage=1 -dLastPage=1 or -sPageList=1 (see Parameter switches (-d and -s)). You could get excellent results with less hassle using pdftocairo or pdftoppm instead of gs (install package poppler-utils on Debian), I've been there... Both tools are able to output JPEG files and the options are straightforward, e.g. pdftocairo -jpeg -singlefile -f 1 -l 1 -scale-to-x 200 -scale-to-y -1 input.pdf thumb to generate thumb.jpg of page 1 with a width of 200px and proportional height.
    – Freddy
    Sep 14, 2020 at 17:00
  • Thanks @Freddy - I didn't have those options listed in the man page. -sPageList=1 did the trick.
    – Basil Bear
    Sep 15, 2020 at 8:48
  • Thanks @MC68020 for that useful suggestion.
    – Basil Bear
    Sep 15, 2020 at 8:54

1 Answer 1

1

The answer (provided by @Freddy) was available in the online documentation:

-sPageList=1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .