my $path = $me->{path};
my $sz = $SIZE{$scale} or die "unknown scale `$scale'";
+ my $url;
+
if ($me->sz <= $sz)
- { return $m->interp->apply_escapes("$IMGURL/$path", "u"); }
-
- my $tail = "scale.$sz/$path";
- my $thumb = "$CACHE/$tail";
- my $thumburl = $m->interp->apply_escapes("$CACHEURL/$tail", "u");
- my $st = stat $thumb;
- if (defined $st && $st->mtime > $me->{mtime}) { return $thumburl; }
- return
- $m->interp->apply_escapes("$SCRIPTURL/$path", "u") . "?scale=$scale"
- unless $forcep;
-
- my ($dir, $base, $ext) = TrivGal::split_path $thumb;
- my $ty = $TYPE{lc $ext} or die "unknown type `$ext'";
-
- my $img = $me->{img};
- unless (defined $img) {
- my $exif = new Image::ExifTool;
- $exif->ExtractInfo($me->{imgpath});
- my $orient = $exif->GetValue("Orientation", "ValueConv");
- $img = $me->{img} = Image::Imlib2->load($me->{imgpath});
- if (defined $orient) {
- my ($rot, $flip) = @{$ORIENT{$orient}};
- if ($rot) { $img->image_orientate($rot); }
- if ($flip) { $img->flip_horizontal(); }
+ { $url = $m->interp->apply_escapes("$IMGURL/$path", "u"); }
+ else {
+ my $tail = "scale.$sz/$path";
+ my $thumb = "$CACHE/$tail";
+ my $thumburl = $m->interp->apply_escapes("$CACHEURL/$tail", "u");
+
+ my $st = stat $thumb;
+ if ($st && $st->mtime > $me->{mtime})
+ { $url = $thumburl; }
+ elsif (!$forcep) {
+ $url =
+ $m->interp->apply_escapes("$SCRIPTURL/$path", "u") .
+ "?scale=$scale";
+ } else {
+ my $img = $me->{img};
+ unless (defined $img) {
+ my $exif = new Image::ExifTool;
+ $exif->ExtractInfo($me->{imgpath});
+ my $orient = $exif->GetValue("Orientation", "ValueConv");
+ $img = $me->{img} = Image::Imlib2->load($me->{imgpath});
+ if (defined $orient) {
+ my ($rot, $flip) = @{$ORIENT{$orient}};
+ if ($rot) { $img->image_orientate($rot); }
+ if ($flip) { $img->flip_horizontal(); }
+ }
+ }
+
+ my ($dir, undef, $ext) = TrivGal::split_path $thumb;
+ my $ty = $TYPE{lc $ext} or die "unknown type `$ext'";
+ my $sc = $sz/$me->sz;
+ my $scaled = $img->create_scaled_image($sc*$wd, $sc*$ht);
+
+ $scaled->image_set_format($ty->imlibfmt);
+ $scaled->set_quality(90);
+ my $new = "$TMP/t$$-$ext";
+ make_path $TMP, { mode => 0771 };
+ $scaled->save($new);
+ make_path $dir, { mode => 0771 };
+ rename $new, $thumb;
+ $url = $thumburl;
}
}
- my $sc = $sz/$me->sz;
- my $scaled = $img->create_scaled_image($sc*$wd, $sc*$ht);
-
- $scaled->image_set_format($ty->imlibfmt);
- $scaled->set_quality(90);
- my $new = "$TMP/t$$-$ext";
- make_path $TMP, { mode => 0771 };
- $scaled->save($new);
- make_path $dir, { mode => 0771 };
- rename $new, $thumb;
- return $thumburl;
+ return $url;
}
}
die "can't index a folder" if $indexp;
} else {
$list = \@f;
- my ($dir, $base, $ext) = split_path $name;
+ my (undef, undef, $ext) = split_path $name;
die "unknown image type" unless $TYPE{lc $ext};
if ($indexp) {
die "two index images" if defined $ix;
closedir $d;
ENT: for my $e (sort @e) {
- my ($dir, $base, $ext) = split_path $e;
+ my (undef, undef, $ext) = split_path $e;
my $dotp = $e =~ /^\./;
my $st = stat "$path/$e";
my $list = undef;