安装:

sudo apt-get install imagemagick

convert id.pdf id.jpeg
convert id.pdf id.png
convert -density 200 id.pdf id.jpg

The simplest command to do the task is ...

$ convert demo.pdf demo.jpg

If the pdf file has multiple pages then imagemagick shall create multiple image files named as demo-1.jpg, demo-2.jpg ... and so on for all pages in the pdf file.
To convert only a particular page from the pdf file use the following command

$ convert demo.pdf[2] demo.jpg

Creating PDF Thumbnail
To create thumbnail, the image just needs to be scaled down using either of the 'scale', 'thumbnail' or 'resize' option.

Here is a quick example.

$ convert -thumbnail x300 demo.pdf[2] demo.jpg

If the pdf has transparency then scaling might result into an image where all white areas turn into black. To fix this the 'flatten' option can be used as follows

$ convert -thumbnail x300 demo.pdf[2] -flatten demo.jpg

The above command shall put a white background in the transparent areas.

  1. Clearer Text and Higher Resolution
    Using the above command you might notice that the text in the resulting image is not clear or sharp. This can be fixed using the 'density' option.

Use a value of around 175 and the text should become clearer than before. Experiment with the value till the desired level of sharpness is achieved.

$ convert -density 200 demo.pdf[2] demo.jpg
  1. Create gif animation of all pages
    Imagemagick can even create a gif animation of all the pages of the pdf. Its as simple as the following command
$ convert -thumbnail x300 -delay 100 demo.pdf demo.gif

The delay parameter defines the delay of animation.

  1. Quality/compression for jpg
    The quality or compression level of jpg images can be specified using the 'quality' option
$ convert demo.pdf[0] -scale x800 -quality 75  -flatten demo75.jpg
本文链接地址:https://const.net.cn/576.html

标签: none

添加新评论