]> sipb.mit.edu Git - ikiwiki.git/commitdiff
img: Generate png format thumbnails for svg images.
authorJoey Hess <joey@kitenet.net>
Wed, 29 Jun 2011 18:40:30 +0000 (14:40 -0400)
committerJoey Hess <joey@kitenet.net>
Wed, 29 Jun 2011 18:40:30 +0000 (14:40 -0400)
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.

IkiWiki/Plugin/img.pm
debian/changelog

index 103f6b2b3510067f10a5eddf86f8e657ba96fe29..b98e843d436b1aed68ca13a12da94ee44a74dd06 100644 (file)
@@ -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;
index cf17d213c1501bfae3042745ca839759789ae270..7b8d84e45e4784b9d7185ca8d1ae6739397f0aa7 100644 (file)
@@ -18,6 +18,7 @@ ikiwiki (3.20110609) UNRELEASED; urgency=low
   * Support svg as a inlinable image type; svg images can be included on a
     page by simply linking to them, or by using the img directive.
     Note that sanitizing svg files is still not addressed.
   * Support svg as a inlinable image type; svg images can be included on a
     page by simply linking to them, or by using the img directive.
     Note that sanitizing svg files is still not addressed.
+  * img: Generate png format thumbnails for svg images.
 
  -- Joey Hess <joeyh@debian.org>  Thu, 09 Jun 2011 10:06:44 -0400
 
 
  -- Joey Hess <joeyh@debian.org>  Thu, 09 Jun 2011 10:06:44 -0400