img: Explicitly detect format if needed

An empty coder name used to detect the format implicitly, but has been
interpreted as a literal part of the filename since ImageMagick 6.9.8-3.
In newer versions, there does not seem to be any way to indicate that
a filename containing ':' is to be taken literally without first
knowing the decoder to use.

Signed-off-by: Simon McVittie <smcv@debian.org>
master
Simon McVittie 2018-02-28 09:51:13 +00:00
parent f446e7ca5f
commit 54095ea655
1 changed files with 8 additions and 1 deletions

View File

@ -125,7 +125,14 @@ sub preprocess (@) {
} }
else { else {
# allow ImageMagick to auto-detect (potentially dangerous) # 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"); error sprintf(gettext("%s image processing disabled in img_allowed_formats configuration"), $format ? $format : "\"$extension\"") unless allowed($format ? $format : "everything");