diff options
author | Daniel Friesel <derf@finalrewind.org> | 2010-09-11 15:23:58 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2010-09-11 15:23:58 +0200 |
commit | 81b599ccac172f1a42a3fed65ea2338cc3328bf0 (patch) | |
tree | f47193909e43b58d75e96d590747d0b1eac9852d /bin/gen-xhtml-thumbnails | |
parent | 37e01869f108f394ed2d93590b4a51b1547c8cb4 (diff) |
archive support
Diffstat (limited to 'bin/gen-xhtml-thumbnails')
-rwxr-xr-x | bin/gen-xhtml-thumbnails | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/bin/gen-xhtml-thumbnails b/bin/gen-xhtml-thumbnails index d93ac3e..c037b16 100755 --- a/bin/gen-xhtml-thumbnails +++ b/bin/gen-xhtml-thumbnails @@ -3,12 +3,17 @@ # License: WTFPL <http://sam.zoy.org/wtfpl> use strict; use warnings; -use Image::Imlib2; -use Getopt::Long; + use constant { DEFAULT_FILEMODE => oct(644), }; +use Archive::Tar; +use Cwd; +use Getopt::Long; +use Image::Imlib2; + + my $directory = '.'; my $thumbdir = "$directory/.thumbs"; my $indexfile = "$directory/index.xhtml"; @@ -22,6 +27,8 @@ my $css_source; my ($dx, $dy); my @files; my $number = 0; +my $create_archive = 0; +my $tar = Archive::Tar->new(); local $| = 1; sub print_progress { @@ -43,6 +50,7 @@ GetOptions( 'n|show-name' => \$thumb_show_names, 't|title=s' => \$title, 'q|quality=i' => \$thumb_quality, + 'x|archive' => \$create_archive, ); if (@ARGV > 0) { @@ -81,9 +89,16 @@ foreach my $file (readdir($dirhandle)) { closedir($dirhandle); +@files = sort { lc($a) cmp lc($b) } @files; + +if ($create_archive) { + print "Adding files to tar archive\n"; + $tar->add_files(@files); +} + print "Generating thumbnails [ - cached | + generated ]\n"; -foreach my $file (sort { lc($a) cmp lc($b) } @files) { +foreach my $file (@files) { my $thumb; if (defined($css_source)) { @@ -151,6 +166,13 @@ foreach my $file (sort { lc($a) cmp lc($b) } @files) { } print "\n"; +if ($create_archive) { + print "Writing tar archive to disk\n"; + $tar->write('images.tar', undef, (split(qr{/}, getcwd))[-1]); + + print $index "</div><div style=\"clear: left;\"><a href=\"images.tar\">archive</a>\n"; +} + print $index <<'EOD'; </div></body> </html> |