Skip to content

Commit

Permalink
gltfpack: Use ERR Base64 embedded data for invalid images
Browse files Browse the repository at this point in the history
This prevents errors around missing images in case we can't find the source image
or can't encode it. Loading the resulting glTF file will result in a PNG decode
error.

Unfortunately, files like this are still treated as invalid by glTF spec/validator.
  • Loading branch information
zeux committed Apr 8, 2024
1 parent dba0bee commit e20baef
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gltf/write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,9 @@ void writeImage(std::string& json, std::vector<BufferView>& views, const cgltf_i

void writeImageError(std::string& json, const char* action, size_t index, const char* uri, const char* reason)
{
(void)json;
append(json, "\"uri\":\"");
append(json, "data:image/png;base64,ERR/");
append(json, "\"");

fprintf(stderr, "Warning: unable to %s image %d (%s), skipping%s%s%s\n", action, int(index), uri ? uri : "embedded", reason ? " (" : "", reason ? reason : "", reason ? ")" : "");
}
Expand Down

0 comments on commit e20baef

Please sign in to comment.