]> sipb.mit.edu Git - ikiwiki.git/commitdiff
add pdf support to the img directive
authorchrysn <chrysn@fsfe.org>
Mon, 7 Apr 2014 09:19:04 +0000 (11:19 +0200)
committerchrysn <chrysn@fsfe.org>
Mon, 7 Apr 2014 09:19:04 +0000 (11:19 +0200)
this is trivial as pdf is supported by imagemagick, and just needs an
explicit mention to enable conversion.

IkiWiki/Plugin/img.pm

index c861d707527df787de6224a82704a7805a576568..ae681f9e65ca975f6dfedcfd87b0b80307975613 100644 (file)
@@ -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);
                                }