Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a JPG preview of a PDF (using the Linux command line)? [closed]

I'm trying to find a method of converting a PDF to high quality JPG previews on a linux box.

I'm currently using ImageMagicK + GhostScript but I have to supersample the images so much to get readable quality that it takes forever to process (30+ seconds on my box for one page).

Does anyone know of a better method where I can achieve high quality previews without having to supersample so much?

Thanks!

like image 791
Mike Avatar asked Feb 26 '23 01:02

Mike


1 Answers

I found pdftoppm installed on my Ubuntu Linux box.

pdftoppm -f 1 -l 1 -scale-to 1024 -png input-file.pdf output-file
  • The output is high-quality when -scale-to px is large
  • The conversion is quite fast
  • My command above creates a preview for just the first page (-f 1 -l 1)
  • Output-file seems to be of the format: output-file-1.png (where 1 is the page number)
like image 76
multipolygon Avatar answered Apr 27 '23 07:04

multipolygon