summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-04-08 12:10:26 +0200
committerDaniel Friesel <derf@finalrewind.org>2021-04-08 12:10:26 +0200
commit82e9fcab440e4f00b0257b60c254bc8f4c4af16b (patch)
tree3c4cd642068a944f4dd5feeb61c9da5ea94080d7
parent4a1125ba1b5bc8490406f81c35545efe29454b87 (diff)
parentaa76f442a611c7fe60bb0d8bfa53fcc334d2dda8 (diff)
Merge branch 'master' of epicentre:var/source/dthumbHEADmaster
-rwxr-xr-xbin/dthumb10
-rwxr-xr-xlib/App/Dthumb.pm20
-rw-r--r--share/css/main.css9
3 files changed, 29 insertions, 10 deletions
diff --git a/bin/dthumb b/bin/dthumb
index 2f6a718..0f323ba 100755
--- a/bin/dthumb
+++ b/bin/dthumb
@@ -24,6 +24,7 @@ GetOptions(
$opt,
qw{
all|a
+ header=s
help|h
no-names|n
quality|q=i
@@ -121,8 +122,9 @@ for their contents.
=item B<-d>, B<--size> I<maxsize> (default: 200)
-Set maximum thumbnail size. Thumbnails are created so that neither width nor
-height exceed I<maxsize> pixels.
+Set maximum thumbnail size. Both width and height will be limited while
+preserving aspect ratio. Thumbnails are created at 2x resolution and
+downscaled via HTML tags to accomodate high-DPI displays.
=item B<-s>, B<--spacing> I<float> (default: 1.1)
@@ -136,6 +138,10 @@ no border at all, etc.
Set HTML document title. Defaults to the basename of the current directory
+=item B<--header> I<file>
+
+Include I<file> contents in the generated HTML, right after the opening div tag.
+
=item B<-q>, B<--quality> I<int> (default: 75)
Set thumbnail quality.
diff --git a/lib/App/Dthumb.pm b/lib/App/Dthumb.pm
index 3d999bc..0e9a095 100755
--- a/lib/App/Dthumb.pm
+++ b/lib/App/Dthumb.pm
@@ -7,7 +7,7 @@ use 5.010;
use App::Dthumb::Data;
use Cwd;
use File::Copy qw(copy);
-use File::Slurp qw(read_dir write_file);
+use File::Slurp qw(read_dir read_file write_file);
use Image::Imlib2;
our $VERSION = '0.2';
@@ -38,11 +38,19 @@ sub new {
$ref->{data} = App::Dthumb::Data->new();
$ref->{data}->set_vars(
- title => $conf{title},
- width => $conf{size} * $conf{spacing} . 'px',
- height => $conf{size} * $conf{spacing} . 'px',
+ title => $conf{title},
+ boxwidth => $conf{size} * $conf{spacing} . 'px',
+ boxheight => $conf{size} * $conf{spacing} . 'px',
+ imgwidth => $conf{size} . 'px',
+ imgheight => $conf{size} . 'px',
);
+ $ref->{html} = $ref->{data}->get('html_start.dthumb');
+
+ if ( $conf{header} ) {
+ $ref->{html} .= read_file( $conf{header} );
+ }
+
return bless( $ref, $obj );
}
@@ -203,8 +211,8 @@ sub create_thumbnail_html {
sub create_thumbnail_image {
my ( $self, $path ) = @_;
- my $thumbdir = $self->{config}->{suffix_thumbs};
- my $thumb_dim = $self->{config}->{size};
+ my $thumbdir = $self->{config}->{dir_thumbs};
+ my $thumb_dim = $self->{config}->{size} * 2;
my ( $basedir, $file ) = ( $path =~ m{ ^ (.*) / ([^/]*) $ }x );
diff --git a/share/css/main.css b/share/css/main.css
index 5554843..ad451ad 100644
--- a/share/css/main.css
+++ b/share/css/main.css
@@ -2,10 +2,15 @@ div.image-container {
text-align: center;
font-size: 80%;
float: left;
- width: /* $width */;
- height: /* $height */;
+ width: /* $boxwidth */;
+ height: /* $boxheight */;
}
div.image-container a {
text-decoration: none;
}
+
+div.image-container img {
+ max-width: /* $imgwidth */;
+ max-height: /* $imgheight */;
+}