Skip to content

Fix displacement when the image is its own map - #1574

Merged
hipstersmoothie merged 2 commits into
jimp-dev:mainfrom
anishpentyala:fix-displace-map-alias
Nov 30, 2026
Merged

hipstersmoothie merged 2 commits into
jimp-dev:mainfrom
anishpentyala:fix-displace-map-alias

Conversation

@anishpentyala

Copy link
Copy Markdown
Contributor

Fix displacement when the image is its own map

displace({ map: image, offset: { x: 2, y: 2 } }) reads map channels from the image while writing displaced pixels into that same buffer. Later pixels can therefore use map values written earlier in the scan. The output differs from using an unchanged clone as the map.

Snapshot the map channels only when its byte range overlaps the destination buffer. Separate maps keep the existing path, including distinct non-overlapping views of one backing buffer. Pixel sampling, edge handling and displacement math are unchanged.

Tests compare self-mapping and overlapping views against a separate-map control, cover numeric and two-axis offsets, and check that a non-overlapping map stays unchanged. On the base, the two-axis self-map regression fails by a pixel-buffer assertion; the other controls pass.

Validation on Node 22.23.5, Linux:

  • All 12 plugin tests pass in Node and headless Chromium.
  • Plugin ESLint and package build pass.
  • Full workspace build passes, including browser-bundle checks (48 build tasks).
  • Full workspace test run exceeded the local time limit, so a full-suite pass is not claimed.

No Windows or macOS runtime tests were run.

@hipstersmoothie
hipstersmoothie merged commit 11232d3 into jimp-dev:main Nov 30, 2026
13 of 14 checks passed
@hipstersmoothie hipstersmoothie added the patch Increment the patch version when merged label Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Increment the patch version when merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants