Repository navigation
Fix a few edge cases when converting RGB images in convertRGBToRGBA and ImageResizer - #22046
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #22046 +/- ##
==========================================
- Coverage 90.37% 90.27% -0.10%
==========================================
Files 269 269
Lines 67230 67235 +5
==========================================
- Hits 60758 60699 -59
- Misses 6472 6536 +64
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
timvandermeij
approved these changes
Oct 2, 2026
timvandermeij
left a comment
Collaborator
There was a problem hiding this comment.
Looks good to me, with the comment above addressed. Thanks!
… and `ImageResizer`
- `convertRGBToRGBA` ignored the `byteOffset` of the source, which isn't zero
when e.g. the data of an uncompressed image is read directly from the file,
and it threw when the source wasn't 4-byte aligned. In that case all the
pixels are now converted one by one.
It also used `len >> 2`, which overflows for sources larger than 2 GiB.
- In `ImageResizer.#rescaleImageData`, when the image had to be converted in
several chunks:
- if the chunk height divided the image height, the last chunk was converted
with the full image height;
- the rows were sampled relatively to each chunk, hence a chunk height which
isn't a multiple of `2 ** K` shifted the sub-sampling grid and left the
last rows of the result empty. They're now sampled on the image grid;
- the chunk height is rounded to a multiple of 4 when possible, in order to
keep the RGB data aligned;
- if not even a single row fitted in the buffer, the loop never ended.
calixteman
force-pushed
the
rgb-to-rgba-alignment
branch
from
October 3, 2026 15:23
e141ba6 to
7594737
Compare
Contributor
Reference testsResults for 7594737 (run, references from mozilla/pdf.js.refs@669ca76240).
The report is kept for 30 days and replaced by the next run. |
sync-pdfs-for-pdf-js Bot
pushed a commit
to mozilla/pdf.js.refs
that referenced
this pull request
Oct 3, 2026
timvandermeij
approved these changes
Oct 3, 2026
This was referenced Nov 3, 2026
This branch was previously deployed
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.
convertRGBToRGBAignored thebyteOffsetof the source, which isn't zero when e.g. the data of an uncompressed image is read directly from the file, and it threw when the source wasn't 4-byte aligned. In that case all the pixels are now converted one by one. It also usedlen >> 2, which overflows for sources larger than 2 GiB.ImageResizer.#rescaleImageData, when the image had to be converted in several chunks:2 ** Kshifted the sub-sampling grid and left the last rows of the result empty. They're now sampled on the image grid;