-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy pathimage_index
executable file
·84 lines (61 loc) · 1.66 KB
/
image_index
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/perl -w
# Last change Time-stamp: <2002-08-03 18:41:14 winter>
=begin comment
Author:
Bruce Winter [email protected] http://misterhouse.net:81
Latest version:
http://misterhouse.net:81/mh/bin
Description:
Create html and thumnails of photos of pictures in the current directory.
Uses image_resize (which uses imagemagick) to create thumnails.
=cut
sub help {
print <<DONE;
$0 creates an html index of photos.
Usage: $0 [OPTIONS]
Options are:
-h, --help Display this help message.
Examples:
image_html
DONE
exit;
}
use strict;
use File::Find;
use Getopt::Long;
# Changes defaults if specified on command line
my $help;
&help if ( !GetOptions( 'help' => \$help ) or $help );
#y $size = '20%';
my $size = '160x120';
#my $size = '80x60';
my $dir = '.';
print "Resizing $dir to $size\n";
system "image_resize --dir $dir --size $size --prefix icon -b 0 -r 0";
# Recurses, starting from within the current directory,
my $prefix = 'icon';
my $html = "<h2>Index of $dir</h2><table><tr>\n";
print "\nReading dirs\n";
find( \&get_img, $dir );
my $count;
sub get_img() {
my ($file) = $_;
if ( -f $file ) {
my ( $root, $ext ) = $file =~ /(.+)\.(.+)/;
return unless $ext and $ext =~ /(jpg|gif)/i;
return if $root =~ /^${prefix}_/;
my $file_icon = "${prefix}_$root.$ext";
$html .= qq[<td>$file<br><a href="$file"><img src="$file_icon"></a></td>\n];
$html .= qq[</tr><tr>\n] unless ++$count % 4;
}
}
$html .= "</tr></table>\n";
open( HTML, ">index.html" );
print HTML $html;
close HTML;
#
# $Log: image_index,v $
# Revision 1.3 2004/02/01 19:24:18 winter
# - 2.87 release
#
#