From 7a3fdf08f3fe4984bc81219a075a8bd3234c7d72 Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Sat, 11 Apr 2020 15:34:44 +0200 Subject: glTF exporter: less naive file format detection for textures --- io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py') diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py index d1579803..c9683baf 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py @@ -103,7 +103,7 @@ def __gather_mime_type(sockets_or_slots, export_image, export_settings): if export_settings["gltf_image_format"] == "AUTO": image = export_image.blender_image() - if image is not None and image.file_format == 'JPEG': + if image is not None and __is_blender_image_a_jpeg(image): return "image/jpeg" return "image/png" @@ -244,3 +244,10 @@ def __get_texname_from_slot(sockets_or_slots, export_settings): elif isinstance(sockets_or_slots[0], bpy.types.MaterialTextureSlot): return sockets_or_slots[0].texture.image.name + + +def __is_blender_image_a_jpeg(image: bpy.types.Image) -> bool: + if image.source != 'FILE': + return False + path = image.filepath_raw.lower() + return path.endswith('.jpg') or path.endswith('.jpeg') or path.endswith('.jpe') -- cgit v1.2.3