tex4ever54 has asked for the wisdom of the Perl Monks concerning the following question:

Greetings: First let me get the obligatory excuses out of the way - I am a total hack in the ways of Perl and have never had any background in any other program or scripting languages so forgive if the examples are I give are head scratchers. Anyway, on to the question!!!
I am working on a program that interacts wih our Oracle based Document Management System that will allow users to grab documents from said program while in another program without having to log in each time. My program goes out and finds the TIFF images it needs than uses them to create a PDF file and display the pdf file thru iexplorer. The problem is that the images were originally scanned at many different page sizes and the way I have set up my PDF creation sub distorts the original image if scanned other than 8.5X11. Is there a way to bring the tiff files in and have the page size scale automatically fit the dimensions if the image? Or is there a way to get each individual image files dimensions and plug those into the script? Sorry for the long winded question - the pdf creation portion of my script is below:
my $pdf = PDF::API2->new(-file=>"$PdfOut"); for ($a=0;$a<=$#TifList;$a++) { $ImgFilePath =join(".",$TifList[$a][1],$TifList[$a][3]); $ImgFilePath=~tr/\\/\//; chomp $ImgFilePath; my $page = $pdf->page; $pdf->preferences(-fit=>1, -fitwindow =>1 ); $page->mediabox(8.5/in, 11/in); my $img = $page->gfx; die("Unable to find image file: $!") unless -e "$ImgFilePath"; my $ImgFile = $pdf->image_tiff("$ImgFilePath"); $ImgFile, .1/in, .1/in, 8.4/in, 10.75/in ); $img->image($ImgFile); } $pdf->save; $pdf->end; system( "start iexplore.exe -e $PdfOut");

Replies are listed 'Best First'.
Re: API2 Working with Tiff's
by oko1 (Deacon) on Apr 16, 2008 at 16:56 UTC

    The first thing you'd need to do is fix your script; what's shown above won't compile. (As to being a hack, you have nothing to worry about: I've seen much, much worse code before. :)

    ### This will be a syntax error: "in" is a bare word $page->mediabox(8.5/in, 11/in); ### This will cause several types of syntax errors $ImgFile, .1/in, .1/in, 8.4/in, 10.75/in );

    Otherwise, the suggestion by olus is a pretty good one: Image::Magick is excellent for any kind of image handling/processing.

    
    -- 
    Human history becomes more and more a race between education and catastrophe. -- HG Wells
    
Re: API2 Working with Tiff's
by olus (Curate) on Apr 16, 2008 at 15:48 UTC

    Consider ImageMagick. With it you should at least be able to scale the images to the desired size.