Re: [PHP] PDF Thumbnails

2005-10-03 Thread [EMAIL PROTECTED]
How do I implement using your script? Do this take all of the files in a
directory and convert them into pdf thumbnails? Where does the directory
path go? Thanks for posting and the help.
 On 9/29/05, Matt Darby [EMAIL PROTECTED] wrote:

 I wrote a script for this; it's designed to run from the command line in
 *nix, but can be triggered via exec():

 Usage: ./pdf2thumb.php source_dir out_dir

 [code]

 #!/usr/local/bin/php

 ?
 function getDirFiles($dirPath){
 $filesArr=array();
 if ($handle = opendir($dirPath)){
 while (false !== ($file = readdir($handle)))
 if ($file != .  $file != ..){$filesArr[] = trim($file);}
 closedir($handle);}
 return $filesArr;
 }

 function usage(){
 echo(USAGE: pdf2thumb source_folder_path
 destination_folder_path\n\n);
 exit;
 }

 if(!isset($argv[1])){usage();}
 substr($argv[1],-1)==/?$path=$argv[1]:$path=$argv[1]./;

 isset($argv[2])?$dest_path=$argv[2]:$dest_path=$path;
 substr($dest_path,-1)==/?$dest_path=$dest_path:$dest_path.=/;

 $total_time=0;
 $total_files=0;

 if(!file_exists($dest_path)){`mkdir $dest_path`;}

 $files=getDirFiles($path);

 for($i=0;$icount($files);$i++){
 if(substr($files[$i],-3)==pdf){
 echo(Converting .$files[$i] );
 $time_start = microtime(true);

 $old_name=$path.$files[$i];
 $new_name=$dest_path.str_replace(.pdf,.jpg,$files[$i]);

 `/usr/bin/convert '$old_name' -thumbnail 240x160 '$new_name'`;

 $time_end = microtime(true);
 $convert_time=round($time_end-$time_start,2);
 echo(Done. ($convert_time seconds)\n);
 $total_time+=$convert_time;
 $total_files++;
 }
 }

 echo(\n---\n);
 echo($total_files files converted in .round($total_time/60,2).
 $minutes (AVG: .round($total_time/$total_files,2).s)\n\n);

 ?

 [/code]

 [EMAIL PROTECTED] wrote:

 You would haven't happen to have an example? I am new to imagemagick. Any
 help would be greatly appreciated.
 
 On 9/26/05, Jim Moseby [EMAIL PROTECTED] wrote:
 
 
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: Monday, September 26, 2005 1:43 AM
 To: php-general@lists.php.net
 Subject: [PHP] PDF Thumbnails
 
 
 I give my users an option to upload pdf files to my site and
 would like them
 to see a thumbnail view of the file once uploaded. Has anyone
 heard of a way
 how to do this?
 
 
 The 'convert' function of ImageMagick will do it.
 
 JM
 
 
 
 
 
 





Re: [PHP] PDF Thumbnails

2005-09-29 Thread Matt Darby
I wrote a script for this; it's designed to run from the command line in 
*nix, but can be triggered via exec():


Usage: ./pdf2thumb.php source_dir out_dir

[code]

#!/usr/local/bin/php

?
function getDirFiles($dirPath){
   $filesArr=array();
   if ($handle = opendir($dirPath)){
   while (false !== ($file = readdir($handle)))
   if ($file != .  $file != ..){$filesArr[] = trim($file);}
   closedir($handle);}
   return $filesArr;
}

function usage(){
   echo(USAGE: pdf2thumb source_folder_path 
destination_folder_path\n\n);

   exit;
}

if(!isset($argv[1])){usage();}
substr($argv[1],-1)==/?$path=$argv[1]:$path=$argv[1]./;

isset($argv[2])?$dest_path=$argv[2]:$dest_path=$path;
substr($dest_path,-1)==/?$dest_path=$dest_path:$dest_path.=/;

$total_time=0;
$total_files=0;

if(!file_exists($dest_path)){`mkdir $dest_path`;}

$files=getDirFiles($path);

for($i=0;$icount($files);$i++){
   if(substr($files[$i],-3)==pdf){
   echo(Converting .$files[$i] );
   $time_start = microtime(true);

   $old_name=$path.$files[$i];
   $new_name=$dest_path.str_replace(.pdf,.jpg,$files[$i]);

   `/usr/bin/convert '$old_name' -thumbnail 240x160 '$new_name'`;

   $time_end = microtime(true);
   $convert_time=round($time_end-$time_start,2);
   echo(Done. ($convert_time seconds)\n);
   $total_time+=$convert_time;
   $total_files++;
   }
}

echo(\n---\n);
echo($total_files files converted in .round($total_time/60,2). 
$minutes (AVG: .round($total_time/$total_files,2).s)\n\n);


?

[/code]

[EMAIL PROTECTED] wrote:


You would haven't happen to have an example? I am new to imagemagick. Any
help would be greatly appreciated.

On 9/26/05, Jim Moseby [EMAIL PROTECTED] wrote:
 


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, September 26, 2005 1:43 AM
To: php-general@lists.php.net
Subject: [PHP] PDF Thumbnails


I give my users an option to upload pdf files to my site and
would like them
to see a thumbnail view of the file once uploaded. Has anyone
heard of a way
how to do this?
 


The 'convert' function of ImageMagick will do it.

JM

   



 





Re: [PHP] PDF Thumbnails

2005-09-26 Thread Frank Arensmeier

Hi.

I've tried some different kinds of setups to do this. And my 
recommendation for you would be Ghostscript, maybe together with 
ImageMagick. Have a look at:


http://www.imagemagick.org/script/index.php
http://www.cs.wisc.edu/~ghost/

regards,
frank
2005-09-26 kl. 07.42 skrev [EMAIL PROTECTED]:

I give my users an option to upload pdf files to my site and would 
like them
to see a thumbnail view of the file once uploaded. Has anyone heard of 
a way

how to do this?



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] PDF Thumbnails

2005-09-26 Thread Jim Moseby
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: Monday, September 26, 2005 1:43 AM
 To: php-general@lists.php.net
 Subject: [PHP] PDF Thumbnails
 
 
 I give my users an option to upload pdf files to my site and 
 would like them
 to see a thumbnail view of the file once uploaded. Has anyone 
 heard of a way
 how to do this?


The 'convert' function of ImageMagick will do it.

JM

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PDF Thumbnails

2005-09-26 Thread [EMAIL PROTECTED]
You would haven't happen to have an example? I am new to imagemagick. Any
help would be greatly appreciated.

On 9/26/05, Jim Moseby [EMAIL PROTECTED] wrote:

  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
  Sent: Monday, September 26, 2005 1:43 AM
  To: php-general@lists.php.net
  Subject: [PHP] PDF Thumbnails
 
 
  I give my users an option to upload pdf files to my site and
  would like them
  to see a thumbnail view of the file once uploaded. Has anyone
  heard of a way
  how to do this?


 The 'convert' function of ImageMagick will do it.

 JM



RE: [PHP] PDF Thumbnails

2005-09-26 Thread Jim Moseby
 You would haven't happen to have an example?  I am new to imagemagick.   
  Any help would be greatly appreciated. 
 
 
Sure!
 
'convert -size 85x110 -raise 10x10 rebate.pdf -resize 85x110 rebate.jpg'
 
Assuming you have ImageMagick loaded, the above will take rebate.pdf and
create an 85x110 thumbnail in .jpg format and raise the edges with a 10
pixel 3-D beveled effect.
 
To call it from PHP, have a look at the exec() function in the manual



[PHP] PDF Thumbnails

2005-09-25 Thread [EMAIL PROTECTED]
I give my users an option to upload pdf files to my site and would like them
to see a thumbnail view of the file once uploaded. Has anyone heard of a way
how to do this?