ckan/ckanext-pdfview

Create PDF thumbnails

Opened this issue · 3 comments

Have an INI option to automatically create thumbnails using ImageMagick and Ghostscript (apt-get install imagemagick ghostscript)

For simplicity, also specify a www-readable directory where thumbnails are created.

The CKAN admin can also optionally specify in the INI file the ImageMagick convert parameters to size the thumbnail. If not specified, default thumbnail will be generated as follows:

convert -thumbnail x300 -background white -alpha remove input_file.pdf[0] output_thumbnail.png

To simplify pulling up the thumbnail in templates, the thumbnail will use the resource ID in the filename - [resource ID]_thumb.png, with [resource ID] being directory-sharded on first two hyphens - e.g. the thumbnail for a PDF with resource ID 9efec242-c83b-46c8-9574-ab5c6e37e11c is stored in /var/lib/ckan/default/thumbnails/9efec242/c83b/46c8-9574-ab5c6e37e11c_thumb.png, assuming the thumbnail directory is set to /var/lib/ckan/default/thumbnails.

The thumbnail will be generated if it doesn't exist when calling can_view. In this way, PDF resources uploaded earlier will have thumbnails as well.

What do you think of this approach @amercader ?

Will just do a generic thumbnail extension instead of one specific to ckanext-pdfview.

Reopening. This became a requirement for one installation which we implemented. Will be an optional feature that's off by default so existing installations will not have a problem.

@jguo144 implemented this already and will submit a PR