From b0cc851a192a87cbaf57758a59a1c6a38797514a Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 27 Feb 2011 16:39:57 +0100 Subject: Update documentation --- bin/dthumb | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'bin') diff --git a/bin/dthumb b/bin/dthumb index 012b911..38e330e 100755 --- a/bin/dthumb +++ b/bin/dthumb @@ -50,13 +50,6 @@ Note that recursion is not yet supported. =over -=item B<-x>, B<--archive> - -Create (and link) an "image.tar" archive containing all full-size image files. -All but the last directories in the files' path are stripped, besides that the -directory structure is preserved. So, if you run dthumb -x in -.../mydir/, the archive will contain mydir/1.jpg, mydir/2.jpg etc. - =item B<-n>, B<--no-names> Do not show image names below thumbnails @@ -94,7 +87,7 @@ None. =item * autodie (Included in core as of perl 5.10.1) -=item * Archive::Tar (subject to change) +=item * Data::Section =item * Image::Imlib2 @@ -104,9 +97,6 @@ None. Thumbnails of changed images are not yet recreated. -When used with B<-x>, the completer tar archive is kept in memory, leading to -enormous memory usage and possibly out-of-memory errors. - =head1 AUTHOR Copyright (C) 2009, 2010 by Daniel Friesel Ederf@chaosdorf.deE -- cgit v1.2.3 From 1647027acdde0c71eda1b781723688f1a53c6076 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 27 Feb 2011 16:51:34 +0100 Subject: Add help/version switches --- bin/dthumb | 3 ++- lib/App/Dthumb.pm | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/dthumb b/bin/dthumb index 38e330e..8c96670 100755 --- a/bin/dthumb +++ b/bin/dthumb @@ -13,11 +13,12 @@ my $opt = {}; GetOptions( $opt, qw{ + help|h size|d=i spacing|s=f no-names|n quality|q=i - archive|x + version|v }, ) or die("Please see perldoc -F $0\n"); diff --git a/lib/App/Dthumb.pm b/lib/App/Dthumb.pm index f525776..f26848f 100755 --- a/lib/App/Dthumb.pm +++ b/lib/App/Dthumb.pm @@ -44,6 +44,7 @@ sub new { sub run { my ($self) = @_; + $self->check_cmd_flags(); $self->read_directories(); $self->create_files(); $self->delete_old_thumbnails(); @@ -51,6 +52,19 @@ sub run { $self->write_out_html(); } +sub check_cmd_flags { + my ($self) = @_; + + if ($self->{config}->{version}) { + say "dthumb version ${VERSION}"; + exit 0; + } + if ($self->{config}->{help}) { + say "Please refer to perldoc -F $0 (or man dthumb)"; + exit 0; + } +} + sub read_directories { my ($self) = @_; my $thumbdir = $self->{config}->{dir_thumbs}; -- cgit v1.2.3 From 00253b6ae7cde1bbe353e465850c9657d9c840da Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 27 Feb 2011 16:56:00 +0100 Subject: dthumb(1): Add FILES section --- bin/dthumb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/dthumb b/bin/dthumb index 8c96670..91286cf 100755 --- a/bin/dthumb +++ b/bin/dthumb @@ -42,9 +42,6 @@ dthumb will create an F with a list (thumbnails) of all images found in the current directory; the thumbnails will link to the images. -The F file will always be created in the current directory, the -thumbnails will be saved in F<.thumbs> below it. - Note that recursion is not yet supported. =head1 OPTIONS @@ -82,6 +79,14 @@ Zero upon success, non-zero otherwise. None. +=head1 FILES + +B always works in the current working directory. It will create the +file F, in which the HTML code for the thumbnail list is saved. + +It also creates two directories: F<.thumbs> for the thumbnail images, and +F<.dthumb>, which contains various data (so far icons and javascript code). + =head1 DEPENDENCIES =over -- cgit v1.2.3 From 48c650ef4122a31e7ef707b889a9806b90a58937 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 27 Feb 2011 18:09:36 +0100 Subject: Add (crude) option to disable lightbox --- bin/dthumb | 7 +++++++ lib/App/Dthumb.pm | 18 +++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'bin') diff --git a/bin/dthumb b/bin/dthumb index 91286cf..fc76350 100755 --- a/bin/dthumb +++ b/bin/dthumb @@ -16,6 +16,7 @@ GetOptions( help|h size|d=i spacing|s=f + no-lightbox|L no-names|n quality|q=i version|v @@ -48,6 +49,12 @@ Note that recursion is not yet supported. =over +=item B<-L>, B<--no-lightbox> + +Disable Javascript lightbox. Note that in the current implementations, this +simple skips installation of the data files. The lightbox link in the HTML +will still be written, leading to 404s on the server. This will be fixed. + =item B<-n>, B<--no-names> Do not show image names below thumbnails diff --git a/lib/App/Dthumb.pm b/lib/App/Dthumb.pm index f26848f..ed1ed72 100755 --- a/lib/App/Dthumb.pm +++ b/lib/App/Dthumb.pm @@ -23,6 +23,7 @@ sub new { $conf->{size} //= 200; $conf->{spacing} //= 1.1; $conf->{quality} //= 75; + $conf->{lightbox} = !$conf->{'no-lightbox'}; $conf->{names} = !$conf->{'no-names'}; $ref->{config} = $conf; @@ -104,14 +105,17 @@ sub create_files { mkdir($thumbdir); } - if (not -d $datadir) { - mkdir($datadir); - } + if ($self->{config}->{lightbox}) { + + if (not -d $datadir) { + mkdir($datadir); + } - for my $file (qw(lightbox.js overlay.png loading.gif close.gif)) { - open(my $fh, '>', "${datadir}/${file}"); - print {$fh} $self->{data}->get($file); - close($fh); + for my $file (qw(lightbox.js overlay.png loading.gif close.gif)) { + open(my $fh, '>', "${datadir}/${file}"); + print {$fh} $self->{data}->get($file); + close($fh); + } } } -- cgit v1.2.3 From c8c5da39dbf4e1fa3a2d0ef57269cd797062ee8d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 27 Feb 2011 18:38:44 +0100 Subject: Add progress bar --- Build.PL | 2 ++ README | 1 + bin/dthumb | 4 ++++ lib/App/Dthumb.pm | 19 ++++++++++++++++++- 4 files changed, 25 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/Build.PL b/Build.PL index 5ec738b..c93bbd7 100644 --- a/Build.PL +++ b/Build.PL @@ -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(); diff --git a/README b/README index 8678cef..f9fd483 100644 --- a/README +++ b/README @@ -4,6 +4,7 @@ Requires: * perl version 5.10 or newer * Data::Section * Image::Imlib2 + * Time::Progress Installation: diff --git a/bin/dthumb b/bin/dthumb index fc76350..f3eb2cd 100755 --- a/bin/dthumb +++ b/bin/dthumb @@ -45,6 +45,8 @@ images. Note that recursion is not yet supported. +During operation, B 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; -- cgit v1.2.3