zeux / meshoptimizer

Mesh optimization library that makes meshes smaller and faster to render
MIT License
5.49k stars 473 forks source link

gltfpack: Fixup image mime type between jpeg/png based on headers #677

Closed zeux closed 4 months ago

zeux commented 4 months ago

Some glTF files exported by non-compliant tool chains may use mimeType: image/png but use JPEG images. While these files are invalid, it would be helpful to make an effort to fix this as the mimeType information is fairly redundant.

This change uses image header patterns defined in glTF specification to override mime type even if it's defined based on the image contents; this is done in readImage so that all consumers (that are mime type dependent!) get the correct result.

arpu commented 4 months ago

i wonder if a case for webp is needed https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_texture_webp/README.md