From 199da926e833a87c90e817f47bbee9d586d195ae Mon Sep 17 00:00:00 2001
From: Campbell Barton <ideasman42@gmail.com>
Date: Thu, 24 Nov 2011 07:11:42 +0000
Subject: [PATCH] fix for exception if the image data cant be loaded

---
 io_import_images_as_planes.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py
index ba3030f2e..1c3989e36 100644
--- a/io_import_images_as_planes.py
+++ b/io_import_images_as_planes.py
@@ -124,12 +124,18 @@ def create_material_for_texture(self, texture):
 
 def create_image_plane(self, context, material):
     img = material.texture_slots[0].texture.image
-    x = img.size[0] / img.size[1]
-    y = 1
+    px, py = img.size
+
+    # can't load data
+    if px == 0 or py == 0:
+        px = py = 1
+
+    x = px / py
+    y = 1.0
 
     if self.use_dimension:
-        x = (img.size[0] * (1.0 / self.factor)) * 0.5
-        y = (img.size[1] * (1.0 / self.factor)) * 0.5
+        x = (px * (1.0 / self.factor)) * 0.5
+        y = (py * (1.0 / self.factor)) * 0.5
 
     verts = [(-x, -y, 0),
              (x, -y, 0),
-- 
GitLab