diff options
-rwxr-xr-x | bin/dthumb | 10 | ||||
-rwxr-xr-x | lib/App/Dthumb.pm | 20 | ||||
-rw-r--r-- | share/css/main.css | 9 |
3 files changed, 29 insertions, 10 deletions
@@ -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 */; +} |