ckan / ckanext-pdfview

PDF viewer for CKAN
GNU Affero General Public License v3.0
26 stars 47 forks source link

Create PDF thumbnails #20

Open jqnatividad opened 9 years ago

jqnatividad commented 9 years ago

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 ?

jqnatividad commented 9 years ago

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

jqnatividad commented 8 years ago

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.

jqnatividad commented 7 years ago

@jguo144 implemented this already and will submit a PR