1998-05-12 10:12:38 +02:00
|
|
|
#!/usr/local/bin/perl
|
1998-08-26 12:35:16 +02:00
|
|
|
#
|
|
|
|
# Combine several images into an index image (e.g., for use as an imagemap).
|
|
|
|
#
|
|
|
|
# Usage: fotoindex [-o outputfile] [templatefile]
|
|
|
|
#
|
|
|
|
# The first three lines give the width and height of the thumbnails and
|
|
|
|
# the number of thumbnails per row. The remaining lines are file names
|
|
|
|
# of the images to be combined.
|
1998-05-12 10:12:38 +02:00
|
|
|
|
1998-08-26 12:35:16 +02:00
|
|
|
open(STDERR, ">/tmp/fotoindex.$$.debug");
|
1998-05-12 10:12:38 +02:00
|
|
|
|
|
|
|
$giftopnm = "/usr/local/bin/giftopnm";
|
|
|
|
$pnmscale = "/usr/local/bin/pnmscale";
|
1998-08-26 12:35:16 +02:00
|
|
|
$pbmmake = "/usr/local/bin/pbmmake";
|
|
|
|
$pnmpaste = "/usr/local/bin/pnmpaste";
|
1998-05-14 10:41:18 +02:00
|
|
|
$cjpeg = "/usr/local/bin/cjpeg";
|
1998-05-12 10:12:38 +02:00
|
|
|
|
1998-08-26 12:35:16 +02:00
|
|
|
if ($ARGV[0] eq "-o") {
|
|
|
|
shift;
|
|
|
|
$outputredirect = ">" . shift;
|
1998-05-12 10:12:38 +02:00
|
|
|
}
|
|
|
|
|
1998-08-26 12:35:16 +02:00
|
|
|
@file = (<>);
|
|
|
|
chomp(@file);
|
1998-05-12 10:12:38 +02:00
|
|
|
|
1998-08-26 12:35:16 +02:00
|
|
|
# Remove empty and comment lines
|
|
|
|
for ($i = 0; $i <= $#file;) {
|
|
|
|
if ($file[$i] =~ m/^(\#|\s*$)/ ) {
|
|
|
|
splice(@file, $i, 1);
|
|
|
|
} else {
|
|
|
|
$i++;
|
1998-05-12 10:12:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-08-26 12:35:16 +02:00
|
|
|
$tnw = shift(@file);
|
|
|
|
$tnh = shift(@file);
|
|
|
|
$fw = shift(@file);
|
|
|
|
$fh = int(($#file + 1 + ($fw - 1)) / $fw);
|
1998-05-12 10:12:38 +02:00
|
|
|
|
1998-08-26 12:35:16 +02:00
|
|
|
system ("$pbmmake " . $fw * $tnw . " " . $fh * $tnh . "> /tmp/fotoindex.$$.1.pnm");
|
1998-05-12 10:12:38 +02:00
|
|
|
|
|
|
|
|
1998-08-26 12:35:16 +02:00
|
|
|
for ($i = 0; $i < $fh; $i ++) {
|
1998-05-12 10:12:38 +02:00
|
|
|
for ($j = 0; $j < $fw; $j++) {
|
1998-08-26 12:35:16 +02:00
|
|
|
$pic = $file[$i * $fw + $j];
|
|
|
|
if (-f $pic) {
|
|
|
|
$cmnd = "$giftopnm $pic | $pnmscale -xysize $tnw $tnh > $pic.$$.pnm";
|
|
|
|
system ($cmnd);
|
|
|
|
system ("$pnmpaste $pic.$$.pnm " . $j * $tnw . " " . $i * $tnh . " /tmp/fotoindex.$$.1.pnm > /tmp/fotoindex.$$.2.pnm");
|
|
|
|
rename ("/tmp/fotoindex.$$.2.pnm", "/tmp/fotoindex.$$.1.pnm");
|
|
|
|
unlink ("$pic.$$.pnm");
|
1998-05-12 10:12:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-08-26 12:35:16 +02:00
|
|
|
system("$cjpeg -progressive /tmp/fotoindex.$$.1.pnm $outputredirect");
|
|
|
|
unlink ("/tmp/fotoindex.$$.1.pnm");
|