Creating thumbnails from non-image assets in Perch 2.5
The new Assets functionality in Perch doesn’t just cover image use and re-use. Any type of file can be treated as an Asset and made available for re-use. Perch creates a nice thumbnail preview of images but it is also possible to have a thumbnail of PDF files and even video automatically created.
Thumbnailing of non-image assets does require that you have certain libraries installed on your server. These are reasonably common, and if you have control of your hosting are a simple install with packages for most operating systems. These are as follows:
- ImageMagick – even if you use GD for image thumbnailing we need ImageMagick available for none-image Assets.
- ghostscript – for PDF files (we’ve found the
libmagickwand-dev
package on Debian/Ubuntu to be the easiest way to get this working) - ffmpeg – for video
If you don’t have these things then Assets will still work fine for you. You’ll just not get the thumbnails.
Technical bit: ImageMagick creates thumbnails by passing out the work to other software on the server that understands the file format in question. It doesn’t know how to deal with things like PDFs, but it knows a man who can, so it silently subcontracts that job out to ghostscript behind the scenes. In the same way, it delegates the job of thumbnailing video files to ffmpeg. Using this technique it should be able to thumbnail almost anything, provided a delegate has been configured that understands how to make an image from that type of file.
In common with everything we do at Perch, we assume that you have the bare minimum of things available to you and then enhance the functionality if you do happen to have the libraries required. However this is a nice little feature when you do have support and if you are developing a site that uses a lot of PDFs for example, it might be worth specifying hosting that will give you the ability to thumbnail them.