diff options
author | chrysn <chrysn@fsfe.org> | 2014-04-07 11:32:25 +0200 |
---|---|---|
committer | chrysn <chrysn@fsfe.org> | 2014-04-07 11:32:25 +0200 |
commit | bcc209eb5acd26e3751c5869cd5c1ebe66b0bf03 (patch) | |
tree | 470783bccc4d9e366b770c51506dced57866dfbb /IkiWiki | |
parent | 6cc43773e728df783e29389680e6bf50d3ef6592 (diff) | |
download | ikiwiki-bcc209eb5acd26e3751c5869cd5c1ebe66b0bf03.tar ikiwiki-bcc209eb5acd26e3751c5869cd5c1ebe66b0bf03.tar.gz |
add pagenumber parameter
this allows picking a page from a pdf. also, this enhances performance
greatly when rendering pdfs, as only the first page is rasterized.
(otherwise, imagemagick would treat the pdf as a list of images, work
with all of them, until finally only the first page gets saved). the
default parameter of 0 will select the single image contained in typical
image files anyway, so no specialcasing between single- and multifile
containers is needed.
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/img.pm | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm index ae681f9e6..fe0ba2ef1 100644 --- a/IkiWiki/Plugin/img.pm +++ b/IkiWiki/Plugin/img.pm @@ -66,12 +66,16 @@ sub preprocess (@) { my $base = IkiWiki::basename($file); my $issvg = $base=~s/\.svg$/.png/i; my $ispdf = $base=~s/\.pdf$/.png/i; + my $pagenumber = exists($params{pagenumber}) ? int($params{pagenumber}) : 0; + if ($pagenumber != 0) { + $base = "p$pagenumber-$base"; + } eval q{use Image::Magick}; error gettext("Image::Magick is not installed") if $@; my $im = Image::Magick->new(); my $imglink; - my $r = $im->Read($srcfile); + my $r = $im->Read("$srcfile\[$pagenumber]"); error sprintf(gettext("failed to read %s: %s"), $file, $r) if $r; my ($dwidth, $dheight); |