Skip to content

fix(main-editor): keep layers on a cropped image when the editor is r… - #871

Closed
saif-ellafi wants to merge 2 commits into
hm21:stablefrom
saif-ellafi:fix/crop-layer-reopen-scale
Closed

saif-ellafi wants to merge 2 commits into
hm21:stablefrom
saif-ellafi:fix/crop-layer-reopen-scale

Conversation

@saif-ellafi

Copy link
Copy Markdown
Contributor

Hi, this PR has been AI-Assisted. I have found, reproduced, debugged, and tested the solution.

Description

Cropped layers drifted when the same image history was opened in a different editor layout. The crop stays a transform on the original image, and layer offsets are distances from the center of the editor body where they were placed. On import, every layer was rescaled from the full decoded image. That size still includes the crop zoom (scaleUser), while lastRenderedImgSize does not, so a marker placed on the cropped image moved relative to the picture as soon as the body size changed.

The export now records the editor body. Each history entry is rescaled with the transform still in effect for that entry: a cropped entry follows the fitted crop window, and a pre-crop entry follows the uncropped frame (originalRenderedSize), not the zoomed decode of a later crop. Undo after reopen therefore leaves pre-crop layers where they were placed.

Related Issue: Closes #

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

saif-ellafi and others added 2 commits September 23, 2026 16:30
…eopened

Layer offsets were rescaled from the full decoded image, which still includes the crop zoom, so markers drifted when the editor body changed. Scale each history entry from the transform in effect for that entry, and keep pre-crop layers on the uncropped frame.

Co-authored-by: Cursor <cursoragent@cursor.com>
A fresh editor decodes the uncropped base before import, so dividing by scaleUser shrank every layer. Scale pre-patch crops from the uncropped frame and cover save/reopen on a new editor.
@saif-ellafi

Copy link
Copy Markdown
Contributor Author

I'll take this PR back. It does not solve the problem as I thought, and in some cases it makes it even worse.

I am not sure how it can be solved, but I'll be disabling the crop tool to avoid frustrations.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant