[cgiapp] define pdf:use-cropbox=true
    Ben 
    php at clutchsem.com
       
    Tue Sep 20 18:19:52 EDT 2011
    
    
  
Hi - new to Perl and this list, but pretty comfortable learning new
languages.  I'm working on a Perl CGI script that takes GET parameters for
filename/path and max image dimensions to scale the image to within max
dimensions (width/height) and create a thumbnail within thumbnail max
dimensions (w/h) and convert the original file, if not a JPG already, to
JPG.  So far I'm good with PNG, JPG, GIF, and some TIFs and have had
marginal success with PDFs.  I can get and convert each page of a multi-page
PDF doc, ending up with page[x] JPGs, but the JPG aren't being cropped
properly - most of the PDF pages are really 2-page spreads (17x11), except
the cover (page[0]) which is only 8.5x11.  The result is the cover JPG
results in essentially an 11x17, but the far right 8.5x11 is white.  I have
Image::Magick (PerlMagick) and GPL Ghostwriter 9.04 installed, but cannot
for the life of me figure out define use-cropbox=true.
 
Sample code - I have tried multiple variations of
$image->Set('pdf:use-cropbox'=>'true');    and just not having any luck with
it:
 
#!/usr/bin/perl --
 
use Image::Magick;
 
my $pdfDoc;
my $newDoc;
my $image;
 
$pdfDoc = "$ENV{DOCUMENT_ROOT}/client\_images/pdftest.pdf";
$newDoc = "$ENV{DOCUMENT_ROOT}/client\_images/large/pdftester.jpg";
 
$image = new Image::Magick; 
$image->Read($pdfDoc."[0]");
$image->Set('pdf:use-cropbox'=>'true');
$image->Write($newDoc); 
undef $image; 
 
print qq~Content-type: text/html\n\n~;
print qq~$pdfDoc\n\n~;
print qq~$newDoc\n\n~;
    
    
More information about the cgiapp
mailing list