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

[bug]: Fit to Bbox not fitting to bbox #7613

Open
1 task done
JPPhoto opened this issue Feb 3, 2025 · 4 comments
Open
1 task done

[bug]: Fit to Bbox not fitting to bbox #7613

JPPhoto opened this issue Feb 3, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@JPPhoto
Copy link
Contributor

JPPhoto commented Feb 3, 2025

Is there an existing issue for this problem?

  • I have searched the existing issues

Operating system

other

GPU vendor

Nvidia (CUDA)

GPU model

RTX 3060

GPU VRAM

12GB

Version number

main

Browser

Chrome

Python dependencies

No response

What happened

Clicking "Fit Bbox To Layers" in canvas doesn't fit the Bbox entirely to the layers. Tested with a 1152x1728 image and the bbox is 1152x1712.

Image

What you expected to happen

The bbox should be set to the maximum dimensions of 1152x1728.

How to reproduce the problem

No response

Additional context

No response

Discord username

No response

@JPPhoto JPPhoto added the bug Something isn't working label Feb 3, 2025
@psychedelicious
Copy link
Collaborator

I can't reproduce this, can you please share the input image?

@JPPhoto
Copy link
Contributor Author

JPPhoto commented Feb 4, 2025

Image

Not sure what the circumstances are that trigger it. Perhaps there was something stale in the browser?

@psychedelicious
Copy link
Collaborator

Thanks, unfortunately it still works fine for me w/ that image.

Can you please get me a debug snapshot of the canvas state:

  • Repro the issue locally
  • Click the canvas settings cog
  • Hold shift to get the Log Debug Info button and click it
  • Open the JS console, copy the managerInfo object and paste here

@psychedelicious
Copy link
Collaborator

Ahh, I know what is happening.

Internally, the bbox is represented as x, y, width, height. The fit logic first snaps the bbox position to the grid (8px for SD1.5/SDXL, 16px for FLUX/SD3, relative to the canvas origin) and then shrinks the width and height to fit. The width and height will be the largest multiple of the grid size that does not overshoot the layer bounds.

So, if the selected model is FLUX, and layer origin y is a multiple of 8 but not a multiple of 16, the bbox will conservatively shift its origin to the nearest multiple of 16 = 8px down. If it does that, it also needs to shrink the height to fit. The result is the bbox is 16px shorter than the layer - the problem described in this issue.

The model-dependent grid snapping approach approximates "smart" snapping (e.g. to layer and bbox bounds), but is only strictly necessary for bbox size. There's no inherent need for positions of anything to be snapped to the grid. It's implemented this way because it's much easier to do this than it is to implement true smart snapping. But, until we have true smart snapping, I don't think we can change this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants