Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly support WebP in the image converter #12224

Merged
merged 5 commits into from
Apr 25, 2024

Conversation

kartben
Copy link
Contributor

@kartben kartben commented Apr 2, 2024

Subject: Fix mime type detection in image converter and add webp->png conversion.

Feature or Bugfix

  • Bugfix

Purpose

Although _image_type_from_file function is able to detect a WEBP header, this could not work due to wrong type of path being passed to guess_mimetype function. As a result, creating a converter from image/webp format to e.g. image/png was not possible.

This PR fixes it by both making it possible to have simple extension based detection of webp files, as well as fixing the code for detection based on actual binary header.

WEBP is not supported in LaTeX - use PNG instead.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Checking mime type of images that might require conversion was broken due to relative path being passed to guess_mimetype() instead of absolute path.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
@kartben kartben changed the title Image conversion fixes Fix mime type detection in image converter and add webp->png conversion. Apr 2, 2024
@picnixz
Copy link
Member

picnixz commented Apr 4, 2024

Could you add tests? I'd like to see an example where it fails and succeeds.

@picnixz picnixz added awaiting:response Waiting for a response from the author of this issue extensions labels Apr 4, 2024
@AA-Turner AA-Turner removed the awaiting:response Waiting for a response from the author of this issue label Apr 25, 2024
@AA-Turner AA-Turner changed the title Fix mime type detection in image converter and add webp->png conversion. Properly support WebP in the image converter Apr 25, 2024
@AA-Turner AA-Turner merged commit a665468 into sphinx-doc:master Apr 25, 2024
23 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2024
@AA-Turner AA-Turner added this to the 7.4.0 milestone Jul 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants