my $imglink;
my $r;
+ my ($dwidth, $dheight);
+
if ($params{size} ne 'full') {
my ($w, $h) = ($params{size} =~ /^(\d+)x(\d+)$/);
return "[[img ".sprintf(gettext('bad size "%s"'), $params{size})."]]"
$r = $im->Read(srcfile($file));
return "[[img ".sprintf(gettext("failed to read %s: %s"), $file, $r)."]]" if $r;
- $r = $im->Resize(geometry => "${w}x${h}");
+ # don't resize any larger
+ my ($rw, $rh) = ($w, $h);
+ if ($rw > $im->Get("width") ||
+ $rh > $im->Get("height")) {
+ $rw=$im->Get("width");
+ $rh=$im->Get("height");
+ }
+
+ $r = $im->Resize(geometry => "${rw}x${rh}");
return "[[img ".sprintf(gettext("failed to resize: %s"), $r)."]]" if $r;
# don't actually write file in preview mode
$imglink = $file;
}
}
+
+ # since we don't really resize larger, set the display
+ # size, so the browser can scale the image up if necessary
+ ($dwidth, $dheight)=($w, $h);
}
else {
$r = $im->Read(srcfile($file));
return "[[img ".sprintf(gettext("failed to read %s: %s"), $file, $r)."]]" if $r;
$imglink = $file;
+ $dwidth = $im->Get("width");
+ $dheight = $im->Get("height");
}
add_depends($imglink, $params{page});
my $imgtag='<img src="'.$imgurl.
'" alt="'.(exists $params{alt} ? $params{alt} : '').
- '" width="'.$im->Get("width").
- '" height="'.$im->Get("height").'"'.
+ '" width="'.$dwidth.
+ '" height="'.$dheight.'"'.
(exists $params{title} ? ' title="'.$params{title}.'"' : '').
(exists $params{class} ? ' class="'.$params{class}.'"' : '').
(exists $params{id} ? ' id="'.$params{id}.'"' : '').
+ikiwiki (2.53.4) UNRELEASED; urgency=low
+
+ * img: Don't generate new verison of image if it is scaled to be
+ larger in either dimension.
+
+ -- Joey Hess <joeyh@debian.org> Fri, 28 Aug 2009 23:42:51 -0400
+
ikiwiki (2.53.3) testing-proposed-updates; urgency=low
* Avoid crash on malformed utf-8 discovered by intrigeri.