summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2012-08-04 21:55:53 +0200
committerJonas Smedegaard <dr@jones.dk>2013-10-13 00:53:28 +0200
commit9c42bbddcb19f792f9920aac077ef02415b76b76 (patch)
tree3558a6bec31997b8617300750798adc31b5ddeb6
parent0f56989346472dd81fcf613a3ab6d6061efb1386 (diff)
Favor Graphics::Macick over Image::Magick if available.
-rw-r--r--IkiWiki/Plugin/img.pm15
1 files changed, 11 insertions, 4 deletions
diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm
index b92e24c..d31febf 100644
--- a/IkiWiki/Plugin/img.pm
+++ b/IkiWiki/Plugin/img.pm
@@ -65,10 +65,17 @@ sub preprocess (@) {
my $dir = $params{page};
my $base = IkiWiki::basename($file);
my $issvg = $base=~s/\.svg$/.png/i;
+ my $usegm = 1;
- eval q{use Image::Magick};
- error gettext("Image::Magick is not installed") if $@;
- my $im = Image::Magick->new($issvg ? (magick => "png") : ());
+ eval q{use Graphics::Magick};
+ if ($@) {
+ $usegm = 0;
+ eval q{use Image::Magick};
+ error gettext("Image::Magick is not installed") if $@;
+ }
+ my $im = $usegm
+ ? Graphics::Magick->new($issvg ? (magick => "png") : ())
+ : 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;
@@ -113,7 +120,7 @@ sub preprocess (@) {
will_render($params{page}, $imglink);
if (-e $outfile && (-M $srcfile >= -M $outfile)) {
- $im = Image::Magick->new;
+ $im = $usegm ? Graphics::Magick->new : Image::Magick->new;
$r = $im->Read($outfile);
error sprintf(gettext("failed to read %s: %s"), $outfile, $r) if $r;
}