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

Composite: don't write to null pixels #1226

Merged

Conversation

sjoerd108
Copy link
Member

@sjoerd108 sjoerd108 commented Apr 22, 2023

What's Changing and Why

This fixes a bug with the composite function which would write garbage data to a pixel at 0, 0 when the target pixel doesn't exist, which can happen when:

  • The source image is bigger than the destination image
  • Using negative x, y offsets

This is because getPixelIndex() returns -1 when using EDGE_CROP which didn't get checked for. So when writing to the target the red channel maps to -1 in the destination buffer, which gets discarded silently (Buffers surprisingly don't throw when you do this) and then the GBA parts of the source get written to the RGB channels on the target.

You can actually see it in the testing image I fixed for this PR: The old "correct" one has a random, off color pixel in the top left, the new one doesn't.

What else might be affected

Should not affect anything.

Tasks

  • Add tests
  • Update Documentation
  • Update jimp.d.ts
  • Add SemVer Label

@hipstersmoothie hipstersmoothie merged commit aec79d0 into jimp-dev:main May 11, 2023
@github-actions
Copy link
Contributor

🚀 PR was released in v0.22.8 🚀

@github-actions github-actions bot added the released This issue/pull request has been released. label May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants