glTF exporter: Better jpeg image detection

This commit is contained in:
Julien Duroure 2022-01-20 18:30:28 +01:00
parent 9be1af0f30
commit 97d4577285
2 changed files with 6 additions and 3 deletions

View File

@ -15,7 +15,7 @@
bl_info = {
'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
"version": (1, 8, 6),
"version": (1, 8, 7),
'blender': (3, 0, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',

View File

@ -261,5 +261,8 @@ def __get_tex_from_socket(blender_shader_socket: bpy.types.NodeSocket, export_se
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')
if image.filepath_raw == '' and image.packed_file:
return image.packed_file.data[:3] == b'\xff\xd8\xff'
else:
path = image.filepath_raw.lower()
return path.endswith('.jpg') or path.endswith('.jpeg') or path.endswith('.jpe')