From: Simon McVittie <smcv@debian.org>
Date: Tue, 16 Sep 2014 08:37:41 +0000 (+0100)
Subject: img: raise an error if we cannot find the image's size
X-Git-Tag: 3.20140916~2
X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/eb4945a3bc03bf062f59006cbed11b03526cefbb

img: raise an error if we cannot find the image's size

This happens for PDFs without ghostscript installed, for instance.
---

diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm
index 54c13d069..17a58ca7a 100644
--- a/IkiWiki/Plugin/img.pm
+++ b/IkiWiki/Plugin/img.pm
@@ -78,7 +78,11 @@ sub preprocess (@) {
 	my $imgdatalink;
 	my $r = $im->Read("$srcfile\[$pagenumber]");
 	error sprintf(gettext("failed to read %s: %s"), $file, $r) if $r;
-	
+
+	if (! defined $im->Get("width") || ! defined $im->Get("height")) {
+		error sprintf(gettext("failed to get dimensions of %s"), $file);
+	}
+
 	my ($dwidth, $dheight);
 
 	if ($params{size} eq 'full') {