Skip to content

feat: add -H --height and -W --width options #1248#1255

Open
opsec-ai wants to merge 2 commits intoleejet:masterfrom
opsec-ai:h_w_pr
Open

feat: add -H --height and -W --width options #1248#1255
opsec-ai wants to merge 2 commits intoleejet:masterfrom
opsec-ai:h_w_pr

Conversation

@opsec-ai
Copy link

@opsec-ai opsec-ai commented Feb 6, 2026

After falling on my face with the first PR, it seemed necessary to get up and try again with a different issue.

Setting the default -H (--height) and -W (--width) options from the sd-server command line.

There is nothing special to this. Manually added .default_width and .default_height to struct SDSvrParams and initialized both endpoints with that, instead 512.

Copy link
Contributor

@wbruna wbruna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameters themselves are already supported by parse_options(). The real issue is simply that the parsed values are always overridden when decoding the API parameters.

@opsec-ai
Copy link
Author

opsec-ai commented Feb 8, 2026

That's because the vast majority of clients/UI's always send a default height and width in the query.

In order to test this, you have to make, or find a special UI that does not send height and width (unless the user specifies).

Example:

# don't send height and width unless specified
            if (width === "0" && height === "0"){
                json_str = JSON.stringify({
                    prompt: prompt,
                    batch_size: parseInt(batch_size),
                    steps:  parseInt(steps)
                });
            } else {
                json_str = JSON.stringify({
                    prompt: prompt,
                    batch_size: parseInt(batch_size),
                    width:  parseInt(width),
                    height: parseInt(height),
                    steps:  parseInt(steps)
                });
            }
            try {
                const send_request = json_str;
                const response = await fetch('http://localhost:1234/sdapi/v1/txt2img', {
                    method: 'POST',
                    headers: { 'Content-Type': 'application/json' },
                    body: send_request
                });
                const result = await response.json();
# do something with result

@wbruna
Copy link
Contributor

wbruna commented Feb 8, 2026

In order to test this, you have to make, or find a special UI that does not send height and width (unless the user specifies).

#1166 behaves like that.

But again, I'm not arguing about the issue, I'm arguing about the change: it doesn't make sense to 'add' those parameters to the server because it should already support them, since the command-line parsing code is shared with the sd-cli.

You must be a dense model (sorry, couldn't resist).

@opsec-ai
Copy link
Author

opsec-ai commented Feb 8, 2026

Right, but the server hard codes 512 as the default. Oh. I see what you mean. They're in default_gen_params

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.

2 participants