diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-02-27 18:38:44 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-02-27 18:38:44 +0100 |
commit | c8c5da39dbf4e1fa3a2d0ef57269cd797062ee8d (patch) | |
tree | 3202be9326487bf83f28c2ba8ee71ebf4f63029e | |
parent | 48c650ef4122a31e7ef707b889a9806b90a58937 (diff) |
Add progress bar
-rw-r--r-- | Build.PL | 2 | ||||
-rw-r--r-- | README | 1 | ||||
-rwxr-xr-x | bin/dthumb | 4 | ||||
-rwxr-xr-x | lib/App/Dthumb.pm | 19 |
4 files changed, 25 insertions, 1 deletions
@@ -21,7 +21,9 @@ my $build = Module::Build->new( 'Data::Section' => 0, 'Getopt::Long' => 0, 'Image::Imlib2' => 0, + 'IO::Handle' => 0, 'MIME::Base64' => 0, + 'Time::Progress' => 0, }, ); $build->create_build_script(); @@ -4,6 +4,7 @@ Requires: * perl version 5.10 or newer * Data::Section * Image::Imlib2 + * Time::Progress Installation: @@ -45,6 +45,8 @@ images. Note that recursion is not yet supported. +During operation, B<dthumb> will show its progress on STDERR. + =head1 OPTIONS =over @@ -104,6 +106,8 @@ F<.dthumb>, which contains various data (so far icons and javascript code). =item * Image::Imlib2 +=item * Time::Progress + =back =head1 BUGS AND LIMITATIONS 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; |