The attached patch allows to integrate PDF thumbnail creation of the first page (cover) via Ghostscript and ImageMagick.
Similar issue / feature request are #257476: Creating thumbnails with Imagecache module API and #164897: Non image file upload preview, but I don't find any specific issue about thumbnail generation for PDF.
With this patch, thumbnail will be generated on file upload and could be seen on upload attachment table when List is selected (or with any logic specified on theme_upload_attachments()).
This patch could be a starting point to build a refined mechanism to display the "cover" (first page) of pdf files on upload (edit) and download (view), if there's interest on developing this feature.
Screenshot for both file upload and node view is attached.
Some notes:
- Tested on Drupal 6.16
- Patch applied on 6.x-1.x-dev
- Direct use of _imageapi_imagemagick_convert() and ImageMagick specific arguments: it works fine with ImageAPI and ImageAPI ImageMagick version 6.x-1.6, but without this module installed you will get surely a WSOD. Maybe the right way to do it is to wrap this new feature on a module_exists or (probably better) to create a submodule with imageapi_imagemagick.module as requirement (with some check on GhostScript too).
-colorspace RGBis used to convert colorpace like CMYK always to RGB (to prevent some issues on images with some browsers like IE)- No additional destination format is added (PNG as default is fine).
Any improvement and suggestion is welcomed.
| Comment | File | Size | Author |
|---|---|---|---|
| PDF thumbnail example on upload and node view (PNG) | 64.71 KB | chirale | |
| upload_preview_pdf_gs_thumbnails.patch | 2.7 KB | chirale |