Skip to content

Conversation

@alexchuber
Copy link
Contributor

@alexchuber alexchuber commented Oct 29, 2025

This PR addresses cases where exporting images to a specific format could lead to invalid images if the browser or platform didn't support it. It is enabled by a change in #17365 (TBD), whereby a mismatch in requested vs. actual mime type now rejects the promise.

  • Before: Requesting a WebP on Safari, for example, would produce a PNG file incorrectly labeled as a WebP.
  • After: If the requested format isn't available in the environment, it safely falls back to PNG and ensures the data is labeled with the correct image/png MIME type. (PNG is the minimum requirement for platforms implementing image encoding)

To achieve this, the internal getImageDataAsync function is now the source of truth for an image's MIME type. It treats the mimeType parameter as a suggestion and returns the image data along with its actual final format. This ensures that if a fallback occurs at this step, the rest of the export pipeline uses the correct type.

…n encoding glTF images (and give _getImageDataAsync a purpose again!)
@bjsplat
Copy link
Collaborator

bjsplat commented Oct 29, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Oct 29, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Oct 29, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Oct 29, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Oct 29, 2025

@alexchuber alexchuber requested a review from bghgary October 29, 2025 20:56
Copy link
Contributor

@bghgary bghgary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@alexchuber alexchuber marked this pull request as ready for review October 29, 2025 23:10
@bjsplat
Copy link
Collaborator

bjsplat commented Oct 29, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Oct 29, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Oct 29, 2025

@deltakosh deltakosh enabled auto-merge (squash) October 29, 2025 23:57
@bjsplat
Copy link
Collaborator

bjsplat commented Oct 30, 2025

1 similar comment
@bjsplat
Copy link
Collaborator

bjsplat commented Oct 30, 2025

@alexchuber alexchuber marked this pull request as draft October 30, 2025 18:07
auto-merge was automatically disabled October 30, 2025 18:07

Pull request was converted to draft

@alexchuber
Copy link
Contributor Author

Closing to merge into #17365.

@alexchuber alexchuber closed this Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants