X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/89af9ecc575c3e7223b0e6bea57f82872f5caa9f..824cf7db1b96a16b080e284bc3ebf90c1f14a203:/IkiWiki/Plugin/img.pm diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm index 740c44f96..b85824345 100644 --- a/IkiWiki/Plugin/img.pm +++ b/IkiWiki/Plugin/img.pm @@ -125,7 +125,14 @@ sub preprocess (@) { } else { # allow ImageMagick to auto-detect (potentially dangerous) - $format = ''; + my $im = Image::Magick->new(); + my $r = $im->Ping(file => $in); + if ($r) { + $format = lc $r; + } + else { + error sprintf(gettext("failed to determine format of %s"), $file); + } } error sprintf(gettext("%s image processing disabled in img_allowed_formats configuration"), $format ? $format : "\"$extension\"") unless allowed($format ? $format : "everything"); @@ -174,6 +181,12 @@ sub preprocess (@) { my $r = $im->Read("$format:$srcfile\[$pagenumber]"); error sprintf(gettext("failed to read %s: %s"), $file, $r) if $r; + if ($config{deterministic}) { + $im->Set('date:create' => 0); + $im->Set('date:modify' => 0); + $im->Set('option' => 'png:exclude-chunk=time'); + } + if (! defined $im->Get("width") || ! defined $im->Get("height")) { error sprintf(gettext("failed to get dimensions of %s"), $file); }