aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki/Plugin/img.pm6
-rw-r--r--doc/ikiwiki/directive/img.mdwn3
2 files changed, 8 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);
diff --git a/doc/ikiwiki/directive/img.mdwn b/doc/ikiwiki/directive/img.mdwn
index cda62b58f..08d158987 100644
--- a/doc/ikiwiki/directive/img.mdwn
+++ b/doc/ikiwiki/directive/img.mdwn
@@ -28,6 +28,9 @@ to the full size version. By default it does; set "link=somepage" to link
to another page instead, or "link=no" to disable the link, or
"link=http://url" to link to a given url.
+The `pagenumber` parameter selects which of multiple images should be rendered;
+this is relevant mainly for GIF and PDF source images.
+
You can also set default values that will be applied to all later images on
the page, unless overridden. Useful when including many images on a page.