How to convert pdf to image on Linux command line

w‮.ww‬lautturi.com
How to convert pdf to image on Linux command line

To convert a PDF file to an image on the Linux command line, you can use the convert command from the imagemagick package. Here is an example of how to use convert to convert a PDF file to a JPEG image:

  1. Install imagemagick by running the following command:
sudo apt-get install imagemagick
  1. Run the convert command and specify the input PDF file and the output JPEG file:
convert input.pdf output.jpg

Replace input.pdf with the name of your PDF file, and output.jpg with the name you want to give to the resulting JPEG image.

By default, convert will convert the first page of the PDF file to an image. If you want to convert a specific page or range of pages, you can use the -page option. For example, to convert pages 2 to 4 of the PDF file, you can use the following command:

convert -page 2-4 input.pdf output.jpg

You can also use the -density option to specify the resolution of the output image. For example, to create a high-resolution image, you can use the following command:

convert -density 300 input.pdf output.jpg
Created Time:2017-10-28 21:39:00  Author:lautturi