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

Occasional TypeError upon pressing the 1:1 button #5

Open
Technologicat opened this issue Sep 1, 2024 · 0 comments
Open

Occasional TypeError upon pressing the 1:1 button #5

Technologicat opened this issue Sep 1, 2024 · 0 comments

Comments

@Technologicat
Copy link

It sometimes happens that w and/or h are of type str, not int. Then trying to compute (w + h) / 2 raises a TypeError, and the image dimensions are not updated.

Unfortunately this only happens sometimes, and I haven't yet figured out exactly when. The last time this hit me, I was in the img2img tab.

What I do know, however, is that this can be fixed by introducing an explicit typecast, like this:

def avg_from_dims(w, h):
    w = int(w)
    h = int(h)
    avg = (w + h) // 2
    if (w + h) % 2 != 0:
        avg += 1
    return avg
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

No branches or pull requests

1 participant