summaryrefslogtreecommitdiff
path: root/lib/App
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-02-27 18:38:44 +0100
committerDaniel Friesel <derf@finalrewind.org>2011-02-27 18:38:44 +0100
commitc8c5da39dbf4e1fa3a2d0ef57269cd797062ee8d (patch)
tree3202be9326487bf83f28c2ba8ee71ebf4f63029e /lib/App
parent48c650ef4122a31e7ef707b889a9806b90a58937 (diff)
Add progress bar
Diffstat (limited to 'lib/App')
-rwxr-xr-xlib/App/Dthumb.pm19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/App/Dthumb.pm b/lib/App/Dthumb.pm
index ed1ed72..2a4ae27 100755
--- a/lib/App/Dthumb.pm
+++ b/lib/App/Dthumb.pm
@@ -10,11 +10,13 @@ use base 'Exporter';
use App::Dthumb::Data;
use Cwd;
use Image::Imlib2;
+use IO::Handle;
+use Time::Progress;
our @EXPORT_OK = ();
our $VERSION = '0.1';
-local $| = 1;
+STDERR->autoflush(1);
sub new {
my ($obj, $conf) = @_;
@@ -29,6 +31,7 @@ sub new {
$ref->{config} = $conf;
$ref->{data} = App::Dthumb::Data->new();
+ $ref->{timer} = Time::Progress->new();
$ref->{html} = $ref->{data}->get('html_start');
@@ -94,6 +97,11 @@ sub read_directories {
@{$self->{files}} = sort { lc($a) cmp lc($b) } @files;
@{$self->{old_thumbnails}} = @old_thumbs;
+
+ $self->{timer}->attr(
+ min => 1,
+ max => scalar @files,
+ );
}
sub create_files {
@@ -132,9 +140,16 @@ sub create_thumbnails {
my ($self) = @_;
for my $file (@{$self->{files}}) {
+
+ print STDERR $self->{timer}->report(
+ "\r\e[KCreating Thumbnails: %p done, %L elapsed, %E remaining",
+ ++$self->{current_file_id},
+ );
+
$self->create_thumbnail_html($file);
$self->create_thumbnail_image($file);
}
+ print "\n";
}
sub create_thumbnail_html {
@@ -219,3 +234,5 @@ sub write_out_html {
# }
# return;
#}
+
+1;