summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-04-29 16:30:12 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2009-04-29 16:30:12 +0200
commitfb40336949e32d436b3bf23d9098722b6ed79c8c (patch)
tree0f3f7254a2501af0bfd075bb38083d402fa46870
parent56aaf758eecf3fd86c21fbf14e4797165ba8f22f (diff)
Improved progressbar
-rwxr-xr-xinclude/gen-xhtml-thumbnails27
1 files changed, 24 insertions, 3 deletions
diff --git a/include/gen-xhtml-thumbnails b/include/gen-xhtml-thumbnails
index 3c64ea9..1ab433c 100755
--- a/include/gen-xhtml-thumbnails
+++ b/include/gen-xhtml-thumbnails
@@ -7,9 +7,24 @@ my $directory = shift || '.';
my $thumbdir = "$directory/.thumbs";
my $indexfile = "$directory/index.xhtml";
my ($file, $image, $thumb);
-my ($dx, $dy, $tx, $ty);
+my ($dx, $dy);
+my @files;
+my $number = 0;
+
+sub print_progress {
+ if (($number % 60) == 0) {
+ if ($number) {
+ printf(" %4d/%d\n", $number, scalar(@files));
+ }
+ printf('[%3d%%] ', $number * 100 / @files);
+ } elsif (($number % 10) == 0) {
+ print ' ';
+ }
+}
+
$| = 1;
open(my $index, '>', $indexfile);
+
print $index <<ficken;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
@@ -27,14 +42,20 @@ if (! -d $thumbdir) {
}
opendir(my $dirhandle, $directory) or die("Cannot open $directory: $!");
-print "Generating thumbnails [ - cached | + generated ]\n";
foreach $file (readdir($dirhandle)) {
- next unless ($file =~ /\.(png|jpe?g)$/i);
+ push(@files, $file) if ($file =~ /\.(png|jpe?g)$/i);
+}
+closedir($dirhandle);
+
+print "Generating thumbnails [ - cached | + generated ]\n";
+foreach $file (@files) {
print $index <<ficken;
<a href="$file"><img src=".thumbs/$file"/></a>
ficken
+ print_progress;
+ $number++;
if (-e "$thumbdir/$file") {
print '-';
next;