summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-02-06 19:10:56 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2010-02-06 19:10:56 +0100
commit4418d3020cc265af2b561280c57adbd2cf10dcdd (patch)
tree9e7bb123291a6d1a49df64143a86d493e6147cb5 /bin
parentd57b71bc36a41210f9e4016682c4651f2d5e60b8 (diff)
Make thumbnail size an option
Diffstat (limited to 'bin')
-rwxr-xr-xbin/gen-xhtml-thumbnails17
1 files changed, 11 insertions, 6 deletions
diff --git a/bin/gen-xhtml-thumbnails b/bin/gen-xhtml-thumbnails
index 155ba1f..00bebf0 100755
--- a/bin/gen-xhtml-thumbnails
+++ b/bin/gen-xhtml-thumbnails
@@ -7,7 +7,6 @@ use Image::Imlib2;
use Getopt::Long;
use constant {
DEFAULT_FILEMODE => oct(644),
- THUMB_MAX_DIM => 150,
THUMB_QUALITY => 60,
THUMB_SPACING => 1.1,
};
@@ -17,6 +16,7 @@ my $thumbdir = "$directory/.thumbs";
my $indexfile = "$directory/index.xhtml";
my $title = '';
my $css_line = '';
+my $thumb_max_dim = 150;
my $css_source;
my ($dx, $dy);
my @files;
@@ -37,6 +37,7 @@ sub print_progress {
GetOptions(
'css=s' => \$css_source,
+ 'size=i' => \$thumb_max_dim,
'title=s' => \$title,
);
@@ -88,8 +89,8 @@ foreach my $file (sort(@files)) {
else {
printf {$index} (
'<div style="float: left; width: %dpx; height: %dpx">',
- THUMB_MAX_DIM * THUMB_SPACING,
- THUMB_MAX_DIM * THUMB_SPACING,
+ $thumb_max_dim * THUMB_SPACING,
+ $thumb_max_dim * THUMB_SPACING,
);
}
@@ -104,12 +105,12 @@ foreach my $file (sort(@files)) {
($dx, $dy) = ($image->width, $image->height);
- if ($dx > THUMB_MAX_DIM and $dy > THUMB_MAX_DIM) {
+ if ($dx > $thumb_max_dim and $dy > $thumb_max_dim) {
if ($dx > $dy) {
- $thumb = $image->create_scaled_image(THUMB_MAX_DIM, 0);
+ $thumb = $image->create_scaled_image($thumb_max_dim, 0);
}
else {
- $thumb = $image->create_scaled_image(0, THUMB_MAX_DIM);
+ $thumb = $image->create_scaled_image(0, $thumb_max_dim);
}
}
else {
@@ -162,6 +163,10 @@ is not supported.
Use I<file> for css definitions
+=item B<--size> I<pixels>
+
+Maximum thumbnail size (either width or height)
+
=item B<--title> I<title>
Use I<title> as <title> for the XHTML output