Get a preview JPEG of a PDF on Windows?

后端 未结 3 1335
一向
一向 2020-12-23 17:17

I have a cross-platform (Python) application which needs to generate a JPEG preview of the first page of a PDF.

On the Mac I am spawning sips. Is there something si

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-23 18:04

    You can use ImageMagick's convert utility for this, see some examples in http://studio.imagemagick.org/pipermail/magick-users/2002-May/002636.html :

    Convert taxes.pdf taxes.jpg 
    

    Will convert a two page PDF file into [2] jpeg files: taxes.jpg.0, taxes.jpg.1

    I can also convert these JPEGS to a thumbnail as follows:

    convert -size 120x120 taxes.jpg.0 -geometry 120x120 +profile '*' thumbnail.jpg
    

    I can even convert the PDF directly to a jpeg thumbnail as follows:

    convert -size 120x120 taxes.pdf -geometry 120x120 +profile '*' thumbnail.jpg
    

    This will result in a thumbnail.jpg.0 and thumbnail.jpg.1 for the two pages.

提交回复
热议问题