Implement a JS WebP encoder/decoder and a PHP WebP decoder#6168
Closed
Implement a JS WebP encoder/decoder and a PHP WebP decoder#6168
Conversation
The previous check was ported from the JS ExifUtil and is meant as a safety check. An earlier version used a slightly different JPEG (that included a JFIF tag) but was replaced to some 30 bytes with this version. This also means that any changes to the encoded image could break the following logic thus we convert it into `assert()` to fail hard if adjusted improperly.
This was referenced Jul 18, 2025
Member
Author
|
Replaced by |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WoltLab Suite 6.1 introduced a new upload pipeline that yields resized images in the much more efficient WebP graphics format.
Part of the resizing process is to strip the EXIF meta data because the underlying nodeca/pica library does not support metadata and discards it. This not only means that the EXIF data is lost but also that any possible image rotation (which is stored in EXIF) is discarded alongside with it. We solved this issue in earlier versions by removing the EXIF data and embedded it into the generated JPEG again.
Unfortunately, there is no library around to accomplish the same in JS for WebP without relying on some CLI binaries.
This PR adds
WoltLab/Core/Image/WebP, a pure JavaScript decoder/encoder for WebP (with focus on VP8X encoding) based on the official specs at https://developers.google.com/speed/webp/docs/riff_container.To add insult to injury, PHP doesn’t support reading EXIF metadata from WebP either, let alone process it in any way. This PR also adds
wcf\system\image\WebPDecoderwhich is a very basic port of our JS WebP decoder but focused on extracting the EXIF chunk only. Parsing the EXIF data is done by creating an empty 100 byte JPEG that serves as the host for the EXIF metadata, allowing us to utilize\exif_read_data().Fixes https://www.woltlab.com/community/thread/310622-bild-liegt-auf-der-seite/