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

#11
[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.

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

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

#14
[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">


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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