]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/img.pm
img: Explicitly detect format if needed
[git.ikiwiki.info.git] / IkiWiki / Plugin / img.pm
index 79cfba20fb48564849b41717907c7f860904fe02..b85824345ed6e1634cf6f43b08ac3887a56117d4 100644 (file)
@@ -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");