Show thumbnails for PDF attachments
If GhostScript is installed, ImageMagick is able to handle PDF files as well. This could be used to create thumbnails for PDF attachments.
The attached patch adds this feature. It is based on current trunk (r15332)
It does a couple of things:
It adds a
This method tries to determine if GhostScript is installed. It does so by checking if GhostScript binaries are found in the PATH. This might be insufficient, since ImageMagick might be configured to use the GhostScript libraries without the binaries being installed. But this is rather unlikely.
This property is also made available in
/admin/info and descriptions for English and German are added.
Attachment#thumbnailable? is extended¶
So that, if GhostScript is available, PDFs are also considered thumbnailable
Redmine::Thumbnail::generate is extended¶
to create PDF thumbnails. Thumbnails will only show the first page (
 at the end of source parameter) and they will be stored in PNG format (
png: at the beginning of target parameter).
AttachmentController#detect_content_type is extended¶
image/png if an attachment thumbnail of a PDF is rendered. In all other cases the thumbnails format used to match the attachment's. But this was not feasible for PDF files.
#1 Updated by Gregor Schmidt about 1 year ago
- File 0001-Render-PDF-thumbnail-using-ImageMagick-GhostScript.patch added
- File pdf-thumb.png added
I have attached an updated patch. The first one (now obsolete) was missing a change in
Attachment, I had introduced locally for the changes in #22482.
I have also added a screen shot previewing the feature.
Gregor, I guess you have to update your patch because of this new feature: https://github.com/redmine/redmine/commit/bf81c96b79cc80bc4ffb08714a3d3f92e68e254a
You can find some hits here: http://www.redmine.org/attachments/16039/pdf_thumbnails.patch
And in addition, I guess you can add tiff support ( is also necessary here, so I'd suggest you to add "" for all images, not only for pdf, it works in my patch as well), and add some tests.
#7 Updated by Gregor Schmidt 12 months ago
Attached you may find an updated patch (trunk r15429)
- File Render-PDF-thumbnail-using-ImageMagick-GhostScript-20170504.patch added
- Target version changed from Candidate for next minor release to 3.4.0
It is a great feature. We can easy guess the content of attached PDF files by seeing its thumbnail.
I updated the patch for the current trunk. Let's deliver this feature in the upcoming version.