Revision: 3521
Updated Code
at August 7, 2007 16:19 by iblis
Updated Code
#!/usr/bin/perl -w
use strict;
use Image::Magick;
# Bundle a bunch of images into a pdf document
#
# Matches files in given directory according to given regex
# and wraps them in a pdf document
die "Usage: $0 path regex [output_filename]\n" if (! defined $ARGV[1]) ;
my $path = shift;
my $regex = shift;
my $output = (defined $ARGV[0]) ? shift : 'bundle.pdf';
# open path or die
opendir DIR, $path
or die "Can't open $path : $!\n";
# build a list of files with full path matching the regex
my @filelist = map {$path . '/' . $_}
grep { -f "$path/$_" && /$regex/}
readdir DIR;
# do not proceed further if file list empty
exit if (!defined $filelist[0]);
# call image magick
my $magick = new Image::Magick(format=>"pdf");
my $status;
$status = $magick->Read(@filelist) and warn "Read failed: $status";
$status = $magick->Write("pdf:$output") and warn "Write failed: $status";
Revision: 3520
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 6, 2007 14:18 by iblis
Initial Code
#!/usr/bin/perl -w
use strict;
use Image::Magick;
# Bundle a bunch of images into a pdf document
#
# Matches files in given directory according given regex
# and wrap them in a pdf document
die "Usage: $0 path regex [output_filename]\n" if (! defined $ARGV[1]) ;
my $path = shift;
my $regex = shift;
my $output = (defined $ARGV[0]) ? shift : 'bundle.pdf';
# open path or die
opendir DIR, $path
or die "Can't open $path : $!\n";
# build a list of files with full path matching the regex
my @filelist = map {$path . '/' . $_}
grep { -f "$path/$_" && /$regex/}
readdir DIR;
# do not proceed further if file list empty
exit if (!defined $filelist[0]);
# call image magick
my $magick = new Image::Magick(format=>"pdf");
my $status;
$status = $magick->Read(@filelist) and warn "Read failed: $status";
$status = $magick->Write("pdf:$output") and warn "Write failed: $status";
Initial URL
Initial Description
Requires PerlMagick.
Initial Title
Bundle a bunch of images into a pdf document
Initial Tags
image, convert
Initial Language
Perl