Return to Snippet

Revision: 3496
at August 2, 2007 08:59 by iblis


Initial Code
#!/usr/bin/perl -w
#
use strict;
use LWP::Simple;
use LWP::UserAgent;
use Image::Magick;
#
die "Aaarg!!\n" if !defined( $ARGV[0] ) ;
#
my $code = shift;
my $pagenb = 0;
my $page = get("http://webapp1.dlib.indiana.edu:8080/metsnav/rifias/navigate.do?oid=r$code");
if ( $page =~ m/\s*<input type.*> of (\d*)/ ) {
	$pagenb = $1;
}
else {
	die "No pages found for $code\n";
}  
#
print "retrieving $pagenb page images\n";
#$pagenb = 2;
#
my $directory = '';
my @filelist;
#
for (my $index=1; $index <= $pagenb ; $index++) {
	my $download = "http://purl.dlib.indiana.edu/iudl/rifias/page/r$code-" . sprintf("%08d", $index) . "-full.gif";
	my $file = sprintf("%03d", $index) . ".gif";
	push(@filelist, $file); 
	my $user_agent = LWP::UserAgent->new;
	my $request = HTTP::Request->new('GET', $download);
	my $response = $user_agent->request ($request, $directory . $file); 
	sleep 2;
}
#
print "preparing $code.pdf out of @filelist\n";
#
my $magick = new Image::Magick( format => "pdf" );
my $status;
$status = $magick->Read( @filelist ) and warn "Read failed: $status";

$status = $magick->Write( "pdf:$code.pdf" ) and warn "Write failed: $status";
#
#system("convert *.gif $code.pdf");

Initial URL

                                

Initial Description
Retrieves gif page images from RIFIAS on-line archive and combines them into a single pdf file

Initial Title
Fetch RIFIAS on-line archive

Initial Tags
perl

Initial Language
Perl