Generating front page thumbnail for uploaded PDF

1,109 views
Skip to first unread message

Lee Jarvis

unread,
Mar 12, 2012, 12:27:08 PM3/12/12
to carri...@googlegroups.com
Hi,

I am using carrierwave to store PDF uploads on S3 and I'm looking to generate a front page PDF thumbnail which users will be able to click and view their PDF's. I'm surprised I have seen little information on this, but I'm struggling. I'm hosting on Heroku so I have a read-only file system

Has anyone else had luck with doing this with carrierwave?

Ed Jones

unread,
Mar 13, 2012, 10:06:23 AM3/13/12
to carri...@googlegroups.com
Not sure what you're asking. You want a small (JPEG?) image of your PDF to display?

Lee Jarvis

unread,
Mar 13, 2012, 11:30:14 AM3/13/12
to carri...@googlegroups.com
That's correct. I want a JPG/PNG image of my PDF to display as a thumbnail. I want to automate this process once a PDF has been uploaded.

Ed Jones

unread,
Mar 13, 2012, 11:40:18 AM3/13/12
to carri...@googlegroups.com
It looks like RMagick will do the conversion. Couldn't quickly find anything on minimagick, but you can check the docs.
http://stackoverflow.com/questions/8083277/rails-image-documents

https://blogs.oracle.com/tdh/entry/pdf_to_jpg_via_imagemagick

Then in your uploader, set up a version
https://github.com/jnicklas/carrierwave
(Scroll to 'Adding Versions')

Ed Jones

unread,
Mar 13, 2012, 11:49:55 AM3/13/12
to carri...@googlegroups.com
LMAO, if you are using the New Google Groups (as I seem to have been shoved into) you will see the very same effect right here.
https://www.google.com/webpagethumbnail?c=5&m=1&r=1&s=175:175&d=https://blogs.oracle.com/tdh/entry/pdf_to_jpg_via_imagemagick&a=AIYkKU-TU9seu2pnOKJXlObK8aYqEKhj2g

Of course, no rails code...



On Monday, March 12, 2012 12:27:08 PM UTC-4, Lee Jarvis wrote:

Lee Jarvis

unread,
Mar 13, 2012, 12:24:19 PM3/13/12
to carri...@googlegroups.com
Thanks for the links. I now have something which reads in the PDF, parses it (via RMagick) and can produce a PNG/JPG, the problem is now integrating this with carrierwave via versions. I need to access the original file path to pass it to RMagick so it can be parsed, RMagick then writes a new image file to the file system, and then it needs to be uploaded.
Reply all
Reply to author
Forward
0 new messages