• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Generating Thumbnails from PDF's

#13
[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!


Messages In This Thread
Generating Thumbnails from PDF's - by El Forum - 07-06-2007, 10:25 AM
Generating Thumbnails from PDF's - by El Forum - 07-06-2007, 01:26 PM
Generating Thumbnails from PDF's - by El Forum - 07-06-2007, 02:06 PM
Generating Thumbnails from PDF's - by El Forum - 07-06-2007, 02:25 PM
Generating Thumbnails from PDF's - by El Forum - 07-06-2007, 02:41 PM
Generating Thumbnails from PDF's - by El Forum - 07-06-2007, 02:51 PM
Generating Thumbnails from PDF's - by El Forum - 07-07-2007, 07:24 PM
Generating Thumbnails from PDF's - by El Forum - 07-17-2007, 01:06 AM
Generating Thumbnails from PDF's - by El Forum - 07-17-2007, 07:40 PM
Generating Thumbnails from PDF's - by El Forum - 07-20-2007, 08:30 AM
Generating Thumbnails from PDF's - by El Forum - 07-31-2007, 04:58 AM
Generating Thumbnails from PDF's - by El Forum - 08-02-2007, 10:29 AM
Generating Thumbnails from PDF's - by El Forum - 08-28-2008, 07:26 AM
Generating Thumbnails from PDF's - by El Forum - 08-28-2008, 01:30 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.