'LibVips pdf to jpg on specific pdf page for multi-page pdf

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?



Solution 1:[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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1