Skip to content

fix: wire -s/-z scale flags and fix format flag handling#1

Open
GobiCowboy wants to merge 1 commit into
yashschandra:mainfrom
GobiCowboy:fix/scale-and-format-flags
Open

fix: wire -s/-z scale flags and fix format flag handling#1
GobiCowboy wants to merge 1 commit into
yashschandra:mainfrom
GobiCowboy:fix/scale-and-format-flags

Conversation

@GobiCowboy
Copy link
Copy Markdown

Summary

  • -s (output-scale) and -z (model-scale) flags were defined but never read or passed to the NCNN binary, silently ignoring user-specified scale
  • Default format "ext/png" was passed directly to the binary, causing Invalid output path extension errors on all runs

Changes

  • run.go: Read -s, -c, -t, -m, -f, -x flags and pass them to upscayl.Input
  • upscayl/upscayl.go: Skip -f when format is empty or the invalid "ext/png" default; derive format from input file extension as fallback

Test

upscayl run -i test.jpg -o test_2x.jpg -s 2   # ✅ 2368x1728 → 4736x3456
upscayl run -i test.jpg -o test_3x.jpg -s 3   # ✅ 2368x1728 → 7104x5184

🤖 Generated with Claude Code

The -s (output-scale) and -z (model-scale) flags were defined in the
CLI but never read or passed to the underlying NCNN binary, making them
silently ignored. Additionally, the default format value "ext/png" was
passed directly to the binary which rejected it, causing "Invalid
output path extension" errors.

- Read -s, -c, -t, -m, -f, -x flags in run.go and pass them to Input
- Skip passing -f when format is empty or the invalid "ext/png" default
- Derive format from input file extension as fallback

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread upscayl/upscayl.go
}
args = append(args, fmt.Sprintf("-m %s", input.ModelPath))
if input.SaveImageAs == "" {
if input.SaveImageAs == "" || input.SaveImageAs == "ext/png" {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Instead of adding a condition here, lets remove the default ext/png set at

cmd.Flags().StringP("format", "f", "ext/png", "Output image format (jpg/png/webp)")

Comment thread run.go
ImageURL: url,
Model: model,
OutputPath: outputPath,
Scale: scaleStr,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We can directly do fmt.Sprintf("%d", outputScale) without defining a new variable to keep code slightly cleaner

Comment thread run.go
OutputPath: outputPath,
Scale: scaleStr,
Compression: fmt.Sprintf("%d", compress),
TileSize: tileSize,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Unfortunately for this (and other tile size related code) to work, we have to pass the value (not pointer)

args = append(args, fmt.Sprintf("-t %d", input.TileSize))

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