-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-html-thumbnail-all-images
executable file
·67 lines (56 loc) · 2 KB
/
create-html-thumbnail-all-images
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
#!/usr/bin/env perl
# v2 - pake 3 buat "frame" horizontal di mana yang kiri adalah link
# teks, yang kedua versi thumbnail, dan yang kanan adalah versi
# besarnya. makin mempermudah quick browsing.
use strict;
use warnings;
use File::Find;
#use HTML::Entities;
#use URI::Escape;
die "index.html already exists!\n" if (-f "index.html");
my $html_links = ".\n<ul>\n";
my $html_thumbs = "";
my $html_fullsize = "";
my $prev_dir = ".";
my $i = 0;
my $re_img_exts = qr/(?:jpe?g|png|gif)/i;
my $re_video_exts = qr/(?:mpe?g|avi|ogm|ogv|rm|rmvb)/i;
my $sub = sub {
return unless -f;
return unless /\.$re_img_exts$/i;
if ($prev_dir ne $File::Find::dir) {
$html_links .= "\n</ul>\n$File::Find::dir\n<ul>\n";
$prev_dir = $File::Find::dir;
}
my $path = "$File::Find::dir/$_";
my $shorten = $_; $shorten =~ s/(?:\.($re_img_exts|$re_video_exts))+$//gi;
my $shorten2 = $_; $shorten2 =~ s/(?:\.($re_img_exts))+$//gi;
$html_links .= "<li><a href=#thumb$i>$shorten</a>\n";
$html_thumbs .= "<a name=thumb$i></a>$shorten<br><a href=#full$i><img src=\"$path\" width=160 border=0></a><br><br>\n";
$html_fullsize .= "<a name=full$i></a>$File::Find::dir<br><big><big><b>$shorten2</b></big></big><br><img src=\"$path\"><br><br><br><br>\n";
$i++;
};
my $sort = sub { sort { lc($a) cmp lc($b) } @_ };
if (!@ARGV) { @ARGV = qw(.) }
finddepth({ wanted => $sub, preprocess => $sort, }, @ARGV);
$html_links .= "</ul>\n";
open F, ">index.html";
print F "<!-- generated by $0 on ".scalar(gmtime)." GMT -->\n";
print F <<_;
<style>
ul { list-style: inside }
.links { position: fixed; width: 200; height: 100%; overflow: scroll }
.thumbs { position: fixed; left: 205; width: 165; height: 100%; overflow: scroll }
.fullsize { position: fixed; left: 375; height: 100%; overflow: scroll }
</style>
<div class=links><small>
$html_links
</small></div>
<div class=thumbs><div align=center>
$html_thumbs
</div></div>
<div class=fullsize><div align=center>
$html_fullsize
</div></div>
_
close F;