CodeIgniter Forums
Generating Thumbnails from PDF's - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Generating Thumbnails from PDF's (/thread-1941.html)

Pages: 1 2


Generating Thumbnails from PDF's - El Forum - 07-31-2007

[eluser]uprocka[/eluser]
hi,

you can change the color profile of CMYK-JPGs to RGB-JPGs with Imagemagick as well - works fine for me though.


Generating Thumbnails from PDF's - El Forum - 08-02-2007

[eluser]Lonely Angel[/eluser]
how? how to use what you said?


Generating Thumbnails from PDF's - El Forum - 08-28-2008

[eluser]Flemming[/eluser]
for what it's worth, a year on, here's what I've done today! I've put it into a model and I call it from a simple controller - but you can use it directly in the controller

Code:
function createPdfJpg($pdf)
{
     $root = $this->config->item('document_root'); // set in config/config.php, eg. /var/www/mysite
     $destination = "/assets/pdfThumbs/";
     $file = basename($pdf); // get the file name including extension, eg. myPdf.pdf
     $filename = substr($file, 0, strrpos($file, '.')); // get the file name minus the extension
     exec("/usr/bin/convert " . escapeshellarg($root.$pdf.'[0]') . " -colorspace RGB -geometry 172x " . escapeshellarg($root.$destination.$filename.".jpg"));    // -geometry 172x creates the jpg at 172px wide (and appropriate height)    
}

It requires ImageMagick and Ghostscript. Hope this helps someone!


Generating Thumbnails from PDF's - El Forum - 08-28-2008

[eluser]Dave Rau[/eluser]
I'd highly recommend <a href="http://phpthumb.sourceforge.net/ ">phpthumb</a> for this task. It handles caching and is super simple to setup; just copy to your server and pass images thru it.

This would turn your cover page in the PDF to a 500px wide JPG:

Code:
<img src="phpthumb_path/phpthumb.php?src=test.pdf&amp;w=500">