1
votes

I'm looking for a way to integrate (my guess is it should be a filter) generation of thumbnails from PDFs into Liip Imagine Bundle for Symfony 2.

So far I know I will need to use ImageMagick as a driver. I did read about custom filters in LiipImagineBundle documentation, but it's very minimal and has no real example, so I'm not entirely sure where to start (therefore I have no code to share here as for that moment).

My only guess here is that my filter should only generate the image from PDF (first page to be accurate) and pass it further to thumbnail filter. This way it will be able to apply other filters as well in the future.

Any advice, guidance or perhaps a short example will be highly appreciated.

1

1 Answers

2
votes

In ImageMagick 6, to create a thumbnail of the first page of a pdf file, you would use:

convert image.pdf[0] -thumbnail WxH image.png

where WxH is your desired thumbnail size. You can also replace WxH by some percent such as 50%. You can change the suffix on the output to jpg or whatever you want.

If you do not get good quality, then add -density 300 before image.pdf[0] to increase the quality of the pdf that is read in.