Implement a JS WebP encoder/decoder and a PHP WebP decoder #6168
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\WebPDecoder
which 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/