"Unable to Import Images as Planes - Float Division Error with PNG Files" #105352

Open
opened 2024-06-13 18:43:19 +02:00 by HKS · 1 comment

System Information
Operating system: widows 11 (23H2)
Graphics card: RTX 3050 4GB VRAM MOBILE gpu 75 tgp
Blender Version
Broken: Blender 4.1.1
Worked: Blender 4.1.1
Short description of error
Unable to import images as planes; receiving a "float division error" when using PNG format.
Exact steps for others to reproduce the error
Based on the default startup or an attached .blend file (as simple as possible).
Open Blender.
Ensure you have the "Import Images as Planes" add-on enabled.
Go to Edit > Preferences.
Navigate to the Add-ons tab.
Search for "Import Images as Planes" and enable it if it's not already.
Go to File > Import > Images as Planes.
Select a PNG image file from your system.
Click Import Images as Planes.
Result: An error message appears, stating "float division error," and the image fails to import.

**System Information** Operating system: widows 11 (23H2) Graphics card: RTX 3050 4GB VRAM MOBILE gpu 75 tgp **Blender Version** Broken: Blender 4.1.1 Worked: Blender 4.1.1 **Short description of error** Unable to import images as planes; receiving a "float division error" when using PNG format. **Exact steps for others to reproduce the error** Based on the default startup or an attached .blend file (as simple as possible). Open Blender. Ensure you have the "Import Images as Planes" add-on enabled. Go to Edit > Preferences. Navigate to the Add-ons tab. Search for "Import Images as Planes" and enable it if it's not already. Go to File > Import > Images as Planes. Select a PNG image file from your system. Click Import Images as Planes. Result: An error message appears, stating "float division error," and the image fails to import.
HKS added the
Status
Needs Triage
Priority
Normal
Type
Report
labels 2024-06-13 18:43:20 +02:00

Hey there, from a quick look at the code it seems that it's a issue with mapping the cameras axis & direction. I assume that you have 'camera' selected in the import settings for plane dimension.
From my current understanding of the code that happens when the camera is looking at the absolute world origin, however i was not yet able to replicate it yet.
You could help by adding some information about your camera and scene setup in your scene to help narrow it down to when it happens. Also include your import settings.

Does this issue happen for every .blend file or just a specific one?

Anyways in my opinion there should be a zero check in line 1185 or a default value for mag in line 1182.

However whilst trying to replicate i found some other interesting issues with this addon when importing images as planes with the plane dimension set to camera (for both fit and fill options); don't know if these should be seperate bug reports though as they seem kind of related:

  • active camera scale is set to 0 (probably a rare case): ValueError: Matrix.invert(ed): matrix does not have an inverse
Python: Traceback (most recent call last):
  File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 936, in execute
    ret_code = self.import_images(context)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 957, in import_images
    planes = [self.single_image_spec_to_plane(context, img_spec) for img_spec in images]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 957, in <listcomp>
    planes = [self.single_image_spec_to_plane(context, img_spec) for img_spec in images]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 993, in single_image_spec_to_plane
    plane = self.create_image_plane(context, material.name, img_spec)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 1120, in create_image_plane
    width, height = self.compute_plane_size(context, img_spec)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 1155, in compute_plane_size
    x, y = compute_camera_size(
           ^^^^^^^^^^^^^^^^^^^^
  File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 216, in compute_camera_size
    distance = world_to_camera_view(scene, camera, center).z
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\modules\bpy_extras\object_utils.py", line 249, in world_to_camera_view
    co_local = obj.matrix_world.normalized().inverted() @ coord
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Matrix.invert(ed): matrix does not have an inverse
  • There is no active camera, e.g. when the active camera got deleted even though there was a second camera in the scene (pressing ctrl + 0 on the second one (to assign it as the new active one) helps avoiding this issue): AttributeError: 'NoneType' object has no attribute 'data'
Python: Traceback (most recent call last):
  File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 936, in execute
    ret_code = self.import_images(context)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 957, in import_images
    planes = [self.single_image_spec_to_plane(context, img_spec) for img_spec in images]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 957, in <listcomp>
    planes = [self.single_image_spec_to_plane(context, img_spec) for img_spec in images]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 993, in single_image_spec_to_plane
    plane = self.create_image_plane(context, material.name, img_spec)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 1120, in create_image_plane
    width, height = self.compute_plane_size(context, img_spec)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 1155, in compute_plane_size
    x, y = compute_camera_size(
           ^^^^^^^^^^^^^^^^^^^^
  File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 205, in compute_camera_size
    view_frame = camera.data.view_frame(scene=scene)
                 ^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'data'
Hey there, from a quick look at the code it seems that it's a issue with mapping the cameras axis & direction. I assume that you have 'camera' selected in the import settings for plane dimension. From my current understanding of the code that happens when the camera is looking at the absolute world origin, however i was not yet able to replicate it yet. You could help by adding some information about your camera and scene setup in your scene to help narrow it down to when it happens. Also include your import settings. Does this issue happen for every .blend file or just a specific one? Anyways in my opinion there should be a zero check in line 1185 or a default value for mag in line 1182. However whilst trying to replicate i found some other interesting issues with this addon when importing images as planes with the plane dimension set to camera (for both fit and fill options); don't know if these should be seperate bug reports though as they seem kind of related: - active camera scale is set to 0 (probably a rare case): `ValueError: Matrix.invert(ed): matrix does not have an inverse` ``` Python: Traceback (most recent call last): File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 936, in execute ret_code = self.import_images(context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 957, in import_images planes = [self.single_image_spec_to_plane(context, img_spec) for img_spec in images] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 957, in <listcomp> planes = [self.single_image_spec_to_plane(context, img_spec) for img_spec in images] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 993, in single_image_spec_to_plane plane = self.create_image_plane(context, material.name, img_spec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 1120, in create_image_plane width, height = self.compute_plane_size(context, img_spec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 1155, in compute_plane_size x, y = compute_camera_size( ^^^^^^^^^^^^^^^^^^^^ File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 216, in compute_camera_size distance = world_to_camera_view(scene, camera, center).z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\modules\bpy_extras\object_utils.py", line 249, in world_to_camera_view co_local = obj.matrix_world.normalized().inverted() @ coord ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: Matrix.invert(ed): matrix does not have an inverse ``` - There is no active camera, e.g. when the active camera got deleted even though there was a second camera in the scene (pressing ctrl + 0 on the second one (to assign it as the new active one) helps avoiding this issue): `AttributeError: 'NoneType' object has no attribute 'data'` ``` Python: Traceback (most recent call last): File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 936, in execute ret_code = self.import_images(context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 957, in import_images planes = [self.single_image_spec_to_plane(context, img_spec) for img_spec in images] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 957, in <listcomp> planes = [self.single_image_spec_to_plane(context, img_spec) for img_spec in images] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 993, in single_image_spec_to_plane plane = self.create_image_plane(context, material.name, img_spec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 1120, in create_image_plane width, height = self.compute_plane_size(context, img_spec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 1155, in compute_plane_size x, y = compute_camera_size( ^^^^^^^^^^^^^^^^^^^^ File "D:\zDownloads\blender-4.1.1-windows-x64\blender-4.1.1-windows-x64\4.1\scripts\addons\io_import_images_as_planes.py", line 205, in compute_camera_size view_frame = camera.data.view_frame(scene=scene) ^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'data' ```
Pratik Borhade added
Status
Needs Information from User
and removed
Status
Needs Triage
labels 2024-06-19 11:15:37 +02:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#105352
No description provided.