Repository: khronosgroup/gltf-blender-io
Issue: RuntimeError: Error: Image 'image22_001.png.001' does not have any image data while exporting image sequence animation as glb file

Issue:
adding an image sequence to a plane as image texture named 'image_001.png' 'image_002.png' 'image_003.png' 'image_004.png' and exporting it as glb returns the following error. 

have tried removing the png from the file name, removing the ### from the file name, setting output properties to different options but same error.

version used:

macOS : 13.3.1 (22E261)
blender : 3.5.0


error:

Python: Traceback (most recent call last):
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/__init__.py", line 718, in execute
    return gltf2_blender_export.save(context, export_settings)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 35, in save
    json, buffer = __export(export_settings)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 52, in __export
    __gather_gltf(exporter, export_settings)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 66, in __gather_gltf
    active_scene_idx, scenes, animations = gltf2_blender_gather.gather_gltf2(export_settings)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py", line 30, in gather_gltf2
    scenes.append(__gather_scene(blender_scene, export_settings))
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 38, in wrapper_cached
    result = func(*args, **kwargs)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py", line 69, in __gather_scene
    node = gltf2_blender_gather_nodes.gather_node(
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py", line 38, in gather_node
    mesh=__gather_mesh(vnode, blender_object, export_settings),
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py", line 246, in __gather_mesh
    result = gltf2_blender_gather_mesh.gather_mesh(blender_mesh,
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 38, in wrapper_cached
    result = func(*args, **kwargs)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_mesh.py", line 61, in gather_mesh
    primitives=__gather_primitives(blender_mesh, uuid_for_skined_data, vertex_groups, modifiers, materials, export_settings),
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_mesh.py", line 147, in __gather_primitives
    return gltf2_blender_gather_primitives.gather_primitives(blender_mesh,
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 38, in wrapper_cached
    result = func(*args, **kwargs)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py", line 83, in gather_primitives
    material = gltf2_blender_gather_materials.gather_material(
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 38, in wrapper_cached
    result = func(*args, **kwargs)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py", line 60, in gather_material
    pbr_metallic_roughness, uvmap_actives_pbr_metallic_roughness = __gather_pbr_metallic_roughness(blender_material, orm_texture, export_settings)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py", line 349, in __gather_pbr_metallic_roughness
    return gltf2_blender_gather_materials_pbr_metallic_roughness.gather_material_pbr_metallic_roughness(
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 38, in wrapper_cached
    result = func(*args, **kwargs)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py", line 18, in gather_material_pbr_metallic_roughness
    base_color_texture, use_active_uvmap_base_color_texture, _ = __gather_base_color_texture(blender_material, export_settings)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py", line 100, in __gather_base_color_texture
    return gltf2_blender_gather_texture_info.gather_texture_info(inputs[0], inputs, export_settings)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py", line 23, in gather_texture_info
    return __gather_texture_info_helper(primary_socket, blender_shader_sockets, 'DEFAULT', filter_type, export_settings)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 38, in wrapper_cached
    result = func(*args, **kwargs)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py", line 44, in __gather_texture_info_helper
    index, factor = __gather_index(blender_shader_sockets, export_settings)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py", line 141, in __gather_index
    return gltf2_blender_gather_texture.gather_texture(blender_shader_sockets, export_settings)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 38, in wrapper_cached
    result = func(*args, **kwargs)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture.py", line 31, in gather_texture
    source, factor = __gather_source(blender_shader_sockets, export_settings)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture.py", line 83, in __gather_source
    return gltf2_blender_gather_image.gather_image(blender_shader_sockets, export_settings)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 38, in wrapper_cached
    result = func(*args, **kwargs)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py", line 47, in gather_image
    buffer_view, factor_buffer_view = __gather_buffer_view(image_data, mime_type, name, export_settings)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 38, in wrapper_cached
    result = func(*args, **kwargs)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py", line 101, in __gather_buffer_view
    data, factor = image_data.encode(mime_type, export_settings)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_image.py", line 136, in encode
    return self.__encode_happy(export_settings), None
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_image.py", line 146, in __encode_happy
    return self.__encode_from_image(self.blender_image(), export_settings)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_image.py", line 228, in __encode_from_image
    return _encode_temp_image(tmp_image, self.file_format, export_settings)
  File "/Applications/Blender.app/Contents/Resources/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_image.py", line 242, in _encode_temp_image
    tmp_image.save()
RuntimeError: Error: Image 'image_001.png.001' does not have any image data





Changed files:
addons/io_scene_gltf2/blender/exp/material/extensions/gltf2_blender_image.py

diff --git a/addons/io_scene_gltf2/blender/exp/material/extensions/gltf2_blender_image.py b/addons/io_scene_gltf2/blender/exp/material/extensions/gltf2_blender_image.py
index bbfc4f34..7aa8a706 100644
--- a/addons/io_scene_gltf2/blender/exp/material/extensions/gltf2_blender_image.py
+++ b/addons/io_scene_gltf2/blender/exp/material/extensions/gltf2_blender_image.py
@@ -215,7 +215,9 @@ class ExportImage:
     def __encode_from_image(self, image: bpy.types.Image, export_settings) -> bytes:
         # See if there is an existing file we can use.
         data = None
-        if image.source == 'FILE' and not image.is_dirty:
+        # Sequence image can't be exported, but it avoid to crash to check that default image exists
+        # Else, it can crash when trying to access a non existing image
+        if image.source in ['FILE', 'SEQUENCE'] and not image.is_dirty:
             if image.packed_file is not None:
                 data = image.packed_file.data
             else: