Tuesday, June 19, 2012

[php]pdf files to thumbnail PHP

godaddy and imagemagick make me unhappy..

[php]pdf files to thumbnail PHP Server Side Scripting forum at WebmasterWorld

"Hi,
i want to generate a previeiw´tghumbnail of a pdf file.
so far i figured out that ghostwrite and imagemagick is needed. so i asked my hoster to install it.

i found a script snippet that should perform this: 
$filename = "foo";
$file1 = "/Library/WebServer/Documents/polo/pdf/$filename.pdf";
$file2 = "/Library/WebServer/Documents/polo/jpg/$filename.jpg";
$result1 = @exec("/sw/bin/gs -q -dNOPAUSE -dBATCH -sDEVICE=jpeg
-sOutputFile=$file2 $file1 2>&1");
$result2 = @exec("/usr/local/bin/convert -resize 120x120 $file2
$file2 2>&1");

i altered this to this 
$filename = "norden";
$file1 = "$filename.pdf";
$file2 = "$filename.jpg";
$result1 = exec("/usr/bin/gs -q -dNOPAUSE -dBATCH -sDEVICE=jpeg -sOutputFile=$file2 $file1 2>&1");
$result2 = exec("/usr/bin/convert -resize 120x120 $file2 $file2 2>&1");
if($result1 && $result2)
{echo "something happend";}

i made a directory with chmod 777 and loaded this script and a pdf called norden.pdf up. when i call this script
"something happens " appears but no jpg is created...."






0 comments:

Post a Comment