Last modified: 2007-08-18 10:00:19 UTC
I'd like to see support for generating thumbnail images from PDF files. Ideally,
the ability to select the page to make a thumbnail of (with page 1 being the
default) and the ability to rotate the resulting image (in multiples of 90
Some syntax examples would be:
[[image:contract.pdf|thumb]] - Would generate a thumbnail of page 1 of the pdf
at the default size
[[image:contract.pdf|thumb|page=4]] - Would generate a thumbnail of page 4 of
the pdf at the default size
[[image:contract.pdf|thumb|rotate=90]] - Would generate a thumbnail of page 1 of
the pdf with a rotation of 90 degrees
Other image modifiers would be unchanged. Also, ImageMagick supports pdf
natively so the hard work is already done.
The reason for requesting rotation modifiers is that some versions of Adobe
Acrobat rotate pages via the PDF header and ImageMagick when generating a
thumbnail of those pages ignores the rotation. Arguably, this is an ImageMagick
bug, but the ability to rotate a thumbnail is available in ImageMagick, and
potentially usefull in non-pdf images as well.
I'd second at least the ability to have it auto-generate thumbnails (or image pages) for the first page of a PDF file. Currently it
outputs an awkward and ugly generic icon (see, i.e. http://commons.wikimedia.org/wiki/Image:Los_Alamos_Primer.pdf). It
should not be hard (since ImageMagick already can rasterize PDFs) to have it just use the first page of the PDF as an image,
and it would really open up the usage of PDFs with MediaWiki.
Created attachment 2492 [details]
Allow generation of pdf thumbnails
This patch adds support for thumbnails for pdf files.
It's a bit hacky right now, but works on a production system and demonstrates
The problem with PDF is that each page can be of a different size and
orientation. This patch deals with this by using identify(1) on the original
image, everytime a thumbnail is created. This works, but is quite costly.
Eventually, the size of every page should be stored in the database. The page
sizes can easily be retrieved using "identify -format '%@\n' $filename"
Note: This patch is against Mediawiki SVN as of today (r16906).
To see the code in action, look here: http://spiele.j-crew.de/wiki/Bild:4gewinntfragen.pdf?uselang=en
This also demonstrates that ImageMagick doesn't correctly rotate pdfs (as Sean Tobin noted).
support for pdf is now available through the PdfHandler extension.