Install ImageMagick.I have used PIL a while ago to work with images. But it made me cry, before I have met sorl-thumbnails. It helped me a lot. But now I have to deal with PDF's. And ImageMagick seems like a complete decision to master it all. It has to convert pdf to my direct desirables - jpeg. So to install ImageMagick I have used brew. Like this:
However there are many other ways to do so, depending on a platform. But I strongly recommend to look at brew.
Anyway installing ImageMagick is tricky. And in order to have it installed to work with pdf's we need to have freetype and ghostscript packages. In case of absence of ghostscript you could have error like so:
wand.exceptions.DelegateError: Postscript delegate failed 'file.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/682
In case of freetype package absence you will have you PDF rendered without fonts. So be sure those 2 are certainly installed.
Installing WandThere are several high level bindings for ImageMagick for python, But I have chosen wand as my favorable here.
This is strongly depends on a platform. But nowdays fortunately I can do:
And I'm happy with it.
Wand is simple enough for my task so I can do convert PDF to image and do simple transformations of my choice with it.
Working with itNow that we have those things installed we may convert a pdf into image and resize it afterwards.
I'm sure there are better solutions here. Note this is a simplified example to show the whole point of this method.
Feel free to suggest better solution in comments.