2

I'm currently transforming pdfs to jpgs using the libvips command line.

vips jpegsave mypdf.pdf myimg.jpg

If a PDF is a multi page PDF then libvips will only transform the first page of the PDF. Is there a way to tell libvips which of the pages in the multi page pdf should be the one that gets transformed to a jpg?

ThreeAccents
  • 1,822
  • 2
  • 13
  • 24

1 Answers1

1
  • Make a single jpeg with all pages

vips copy "a.pdf[n=-1]" a.jpg

  • Make a single jpeg with 2 pages

vips copy "a.pdf[n=2]" a.jpg

  • Make a single jpeg with second page

vips copy "a.pdf[page=2]" a.jpg

Make a single jpeg - starting from second page of pdf and total of 3 pages

vips copy "a.pdf[page=2,n=3]" a.jpg

Make multiple jpeg - from page i ( looping in bash - specific to linux )

i=0;while vips copy "a.pdf[page=$i]" a$i.jpg; do ((i++)); done

Deepan Prabhu Babu
  • 862
  • 11
  • 18
  • thanks @jcuitt - i used the above link – Deepan Prabhu Babu Apr 17 '22 at 20:03
  • Hi, I'm using this "i=0;while vips copy "a.pdf[page=$i]" a$i.jpg; do ((i++)); done" and I always get pdfload: pages out of range even though all images are extracted successfully. Any reason why please? – Dev Dev Aug 15 '22 at 20:19