Screenshot pdf from AWS hosted django app

44 views
Skip to first unread message

Ralph Lewis

unread,
Jul 25, 2014, 7:00:17 PM7/25/14
to django...@googlegroups.com
I am hosting a django webapp in AWS and that is running fine, no errors. I now want to be able to take a screenshot of the first page of any pdf that is uploaded to the webapp. I have not had any luck trying to screenshot a pdf with python. I have heard this can be done with PythonMagick, however, I have not been able to get ImageMagick to work on my local dev instance. Any guidance would be excellent.

Lee Hinde

unread,
Jul 25, 2014, 8:03:58 PM7/25/14
to django...@googlegroups.com

On Fri, Jul 25, 2014 at 4:00 PM, Ralph Lewis <ralph.l...@gmail.com> wrote:
I am hosting a django webapp in AWS and that is running fine, no errors. I now want to be able to take a screenshot of the first page of any pdf that is uploaded to the webapp. I have not had any luck trying to screenshot a pdf with python. I have heard this can be done with PythonMagick, however, I have not been able to get ImageMagick to work on my local dev instance. Any guidance would be excellent.


cmawe...@gmail.com

unread,
Jul 31, 2014, 12:15:20 PM7/31/14
to django...@googlegroups.com
I just use commandline imagemagick instead of PythonMagic, if the python bindings are the issue getting imagemagick to work.

cmd = 'convert -density 300 -flatten -interlace line -quality 92 -colorspace sRGB -thumbnail'.split() + size + [default_storage.path(name) + '[0]', 'jpg:-']
proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
stdout, stderr = proc.communicate()
assert not proc.returncode, stderr + stdout
default_storage.save(request.path[1:], ContentFile(stdout))

cmawe...@gmail.com

unread,
Jul 31, 2014, 12:16:29 PM7/31/14
to django...@googlegroups.com
And if local dev is an issue, you could try setting MEDIA_URL to your live site.
Reply all
Reply to author
Forward
0 new messages