Skip to content

Allow Lua image generation to set NovelAI orientation - #1607

Open
enzi221 wants to merge 4 commits into
kwaroran:mainfrom
enzi221:feat/landscaping
Open

enzi221 wants to merge 4 commits into
kwaroran:mainfrom
enzi221:feat/landscaping

Conversation

@enzi221

@enzi221 enzi221 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

PR Checklist

  • Required Checks
    • Have you added type definitions?
    • Have you tested your changes?
    • Have you checked that it won't break any existing features?
  • If your PR uses models1, check the following:
    • Have you checked if it works normally in all models?
    • Have you checked if it works normally in all web, local, and node-hosted versions? If it doesn't, have you blocked it in those versions?
  • If your PR is highly AI generated2, check the following:
    • Have you understood what the code does?
    • Have you cleaned up any unnecessary or redundant code?
    • Is it not a huge change?
      • We currently do not accept highly AI generated PRs that are large changes.

Summary

Lua generateImage() may set its own orientation.

To prevent troll scripts draining NAI credits, the script can't modify dimension but only its orientation.

  • If w/h set to 1000/500 (landscape)
    • No orientation (default, backward compat) => 1000/500
    • Portrait => 500/1000
    • Landscape => 1000/500

Related Issues

None

Changes

Lua generateImage() now expects up to 4 parameters.

NAI branch of stableDiff.ts calls a new function, applyImageOrientation().

Impact

None, backward compatible.

Footnotes

  1. Modifies the behavior of prompting, requesting, or handling responses from AI models. ↩

  2. Over 80% of the code is AI generated. ↩

@cubicj cubicj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I went through 1dbdede on this. applyImageOrientation only reorders the two configured edges, so the pixel count a script can request stays exactly what the settings allow, and the Variety+ sigma comes out identical since it is computed from the product. Only the NovelAI branch reads options, and the other five generateAIImage callers still pass four arguments, so their request bodies are unchanged from main. I also checked the Lua side with wasmoon directly, and a {orientation='portrait'} table arrives as a plain object while an omitted or nil fourth argument takes the default path as described.

Just one thing to flag, not blocking. A non-table fourth argument such as a bare 'portrait' string has no orientation field, so it skips the check and generates at the configured orientation without the error string coming back. pnpm check, pnpm test, and pnpm build are clean on this head.

Approving — thanks for the contribution!

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