From c73f1cbde0f59287d56bfa603b8fd9a70d7fa2d0 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Tue, 23 Mar 2021 17:58:56 +0100 Subject: sync with ikiwiki 3.20180228 --- IkiWiki/Plugin/img.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm index 79cfba2..b858243 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"); -- cgit v1.2.3