X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/ac4883dd4a1fab814c77cc90df1a02776e7e28d0..669a5f5ecc0d50daf96d8dc2af219c94c8625fb4:/IkiWiki/Plugin/img.pm diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm index bd527c8c8..b92e24cc0 100644 --- 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 $issvg = $base=~s/\.svg$/.png/i; 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; @@ -117,7 +118,6 @@ sub preprocess (@) { 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; @@ -131,9 +131,10 @@ sub preprocess (@) { $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 { @@ -152,8 +153,8 @@ sub preprocess (@) { $imgurl=urlto($imglink, $params{destpage}); } else { - $fileurl="$config{url}/$file"; - $imgurl="$config{url}/$imglink"; + $fileurl=urlto($file); + $imgurl=urlto($imglink); } if (! exists $params{class}) {