aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/img.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2011-06-29 14:40:30 -0400
committerJoey Hess <joey@kitenet.net>2011-06-29 14:40:30 -0400
commitae1857b43cf55a393a507b8434f172cbdb29d5b0 (patch)
tree60e038310418c7e250bd0958408eb3bec9c143b2 /IkiWiki/Plugin/img.pm
parentc90bc78d440d63b0ea2f62146edc54e88fb97c32 (diff)
downloadikiwiki-ae1857b43cf55a393a507b8434f172cbdb29d5b0.tar
ikiwiki-ae1857b43cf55a393a507b8434f172cbdb29d5b0.tar.gz
img: Generate png format thumbnails for svg images.
Imagemagick does not generate svg images very well, but it can convert them to png quite well. For browsers that don't yet support displaying svg, this also provides a workaround; just scale the svg down to get a png. But the workaround is partial, since scaling the image larger, or leaving it the same size will cause the original svg to be displayed. Since browsers are actively improving svg support, this is good enough for me.
Diffstat (limited to 'IkiWiki/Plugin/img.pm')
-rw-r--r--IkiWiki/Plugin/img.pm3
1 files changed, 2 insertions, 1 deletions
diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm
index 103f6b2b3..b98e843d4 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;