Photos
Blog
Projects
vanrenterghem.biz
projects
/
git.ikiwiki.info.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
I am bad at formatting.
[git.ikiwiki.info.git]
/
IkiWiki
/
Plugin
/
img.pm
diff --git
a/IkiWiki/Plugin/img.pm
b/IkiWiki/Plugin/img.pm
index 2375ead8968b6a9baf64ff8ac825dbde6a75b82d..b92e24cc06fb93d8d88adcf1517903e46e49dc25 100644
(file)
--- a/
IkiWiki/Plugin/img.pm
+++ b/
IkiWiki/Plugin/img.pm
@@
-64,10
+64,11
@@
sub preprocess (@) {
my $dir = $params{page};
my $base = IkiWiki::basename($file);
my $dir = $params{page};
my $base = IkiWiki::basename($file);
+ my $issvg = $base=~s/\.svg$/.png/i;
eval q{use Image::Magick};
error gettext("Image::Magick is not installed") if $@;
eval q{use Image::Magick};
error gettext("Image::Magick is not installed") if $@;
- my $im = Image::Magick->new;
+ my $im = Image::Magick->new
($issvg ? (magick => "png") : ())
;
my $imglink;
my $r = $im->Read($srcfile);
error sprintf(gettext("failed to read %s: %s"), $file, $r) if $r;
my $imglink;
my $r = $im->Read($srcfile);
error sprintf(gettext("failed to read %s: %s"), $file, $r) if $r;
@@
-117,7
+118,6
@@
sub preprocess (@) {
error sprintf(gettext("failed to read %s: %s"), $outfile, $r) if $r;
}
else {
error sprintf(gettext("failed to read %s: %s"), $outfile, $r) if $r;
}
else {
- ($dwidth, $dheight)=($w, $h);
$r = $im->Resize(geometry => "${w}x${h}");
error sprintf(gettext("failed to resize: %s"), $r) if $r;
$r = $im->Resize(geometry => "${w}x${h}");
error sprintf(gettext("failed to resize: %s"), $r) if $r;
@@
-131,9
+131,10
@@
sub preprocess (@) {
$imglink = $file;
}
}
$imglink = $file;
}
}
-
- $dwidth = $im->Get("width") unless defined $dwidth;
- $dheight = $im->Get("height") unless defined $dheight;
+
+ # always get the true size of the resized image
+ $dwidth = $im->Get("width");
+ $dheight = $im->Get("height");
}
}
else {
}
}
else {
@@
-152,14
+153,11
@@
sub preprocess (@) {
$imgurl=urlto($imglink, $params{destpage});
}
else {
$imgurl=urlto($imglink, $params{destpage});
}
else {
- $fileurl=
"$config{url}/$file"
;
- $imgurl=
"$config{url}/$imglink"
;
+ $fileurl=
urlto($file)
;
+ $imgurl=
urlto($imglink)
;
}
}
- if (exists $params{class}) {
- $params{class}.=" img";
- }
- else {
+ if (! exists $params{class}) {
$params{class}="img";
}
$params{class}="img";
}