From: chrysn Date: Mon, 7 Apr 2014 09:19:04 +0000 (+0200) Subject: add pdf support to the img directive X-Git-Tag: 3.20140916~41^2~10 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/6cc43773e728df783e29389680e6bf50d3ef6592?ds=sidebyside;hp=71b9ad33e04bd131e1d46cf0857ff83ed7407ba3 add pdf support to the img directive this is trivial as pdf is supported by imagemagick, and just needs an explicit mention to enable conversion. --- diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm index c861d7075..ae681f9e6 100644 --- a/IkiWiki/Plugin/img.pm +++ b/IkiWiki/Plugin/img.pm @@ -65,6 +65,7 @@ sub preprocess (@) { my $dir = $params{page}; my $base = IkiWiki::basename($file); my $issvg = $base=~s/\.svg$/.png/i; + my $ispdf = $base=~s/\.pdf$/.png/i; eval q{use Image::Magick}; error gettext("Image::Magick is not installed") if $@; @@ -124,7 +125,7 @@ sub preprocess (@) { # don't actually write resized file in preview mode; # rely on width and height settings if (! $params{preview}) { - $im->set($issvg ? (magick => 'png') : ()); + $im->set(($issvg || $ispdf) ? (magick => 'png') : ()); my @blob = $im->ImageToBlob(); writefile($imglink, $config{destdir}, $blob[0], 1); }