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

<p>On the Mac I am spawning <a href="http://web.archive.org/web/20090309234215/http://developer.apple.com:80/documentation/Darwin/Reference/ManPages/man1/sips.1.html" rel="noreferrer">sips</a>.  Is there something similarly simple I can do on Windows?</p>

[{'answer_id': 536, 'author': 'Federico Builes', 'author_id': 161, 'author_profile': 'https://Stackoverflow.com/users/161', 'pm_score': 4, 'selected': False, 'text': '<p>You can use ImageMagick\'s convert utility for this, see some examples in <a href="https://web.archive.org/web/20120413111338/http://studio.imagemagick.org/pipermail/magick-users/2002-May/002636.html" rel="noreferrer">http://studio.imagemagick.org/pipermail/magick-users/2002-May/002636.html</a>\n:</p>\n\n<blockquote>\n<pre><code>Convert taxes.pdf taxes.jpg \n</code></pre>\n  \n  <p>Will convert a two page PDF file into [2] jpeg files: taxes.jpg.0,\n  taxes.jpg.1</p>\n  \n  <p>I can also convert these JPEGS to a thumbnail as follows:</p>\n\n<pre><code>convert -size 120x120 taxes.jpg.0 -geometry 120x120 +profile \'*\' thumbnail.jpg\n</code></pre>\n  \n  <p>I can even convert the PDF directly to a jpeg thumbnail as follows:</p>\n\n<pre><code>convert -size 120x120 taxes.pdf -geometry 120x120 +profile \'*\' thumbnail.jpg\n</code></pre>\n  \n  <p>This will result in a thumbnail.jpg.0 and thumbnail.jpg.1 for the two\n  pages.</p>\n</blockquote>\n'}, {'answer_id': 7073, 'author': 'Dominic Cooney', 'author_id': 878, 'author_profile': 'https://Stackoverflow.com/users/878', 'pm_score': 3, 'selected': False, 'text': '<p>Is the PC likely to have Acrobat installed? I think Acrobat installs a shell extension so previews of the first page of a PDF document appear in Windows Explorer\'s thumbnail view. You can get thumbnails yourself via the IExtractImage COM API, which you\'ll need to wrap. <a href="http://www.vbaccelerator.com/home/net/code/libraries/shell_projects/Thumbnail_Extraction/article.asp" rel="noreferrer">VBAccelerator has an example in C#</a> that you could port to Python.</p>\n'}, {'answer_id': 7090, 'author': 'C. K. Young', 'author_id': 13, 'author_profile': 'https://Stackoverflow.com/users/13', 'pm_score': 6, 'selected': True, 'text': "<p>ImageMagick delegates the PDF->bitmap conversion to GhostScript anyway, so here's a command you can use (it's based on the actual command listed by the <code>ps:alpha</code> delegate in ImageMagick, just adjusted to use JPEG as output):</p>\n\n<pre><code>gs -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT \\\n-dMaxBitmap=500000000 -dLastPage=1 -dAlignToPixels=0 -dGridFitTT=0 \\\n-sDEVICE=jpeg -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r72x72 \\\n-sOutputFile=$OUTPUT -f$INPUT\n</code></pre>\n\n<p>where <code>$OUTPUT</code> and <code>$INPUT</code> are the output and input filenames. Adjust the <code>72x72</code> to whatever resolution you need. (Obviously, strip out the backslashes if you're writing out the whole command as one line.)</p>\n\n<p>This is good for two reasons:</p>\n\n<ol>\n<li>You don't need to have ImageMagick installed anymore. Not that I have anything against ImageMagick (I love it to bits), but I believe in simple solutions.</li>\n<li>ImageMagick does a two-step conversion. First PDF->PPM, then PPM->JPEG. This way, the conversion is one-step.</li>\n</ol>\n\n<p>Other things to consider: with the files I've tested, PNG compresses better than JPEG. If you want to use PNG, change the <code>-sDEVICE=jpeg</code> to <code>-sDEVICE=png16m</code>.</p>\n"}]
['https://Stackoverflow.com/questions/502', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/147/']