Skip to content

feat: add --res and --aspectratio flags for custom output dimensions#25

Open
hai-pilgrim wants to merge 1 commit into
marksverdhei:mainfrom
hai-pilgrim:feat/custom-resolution
Open

feat: add --res and --aspectratio flags for custom output dimensions#25
hai-pilgrim wants to merge 1 commit into
marksverdhei:mainfrom
hai-pilgrim:feat/custom-resolution

Conversation

@hai-pilgrim
Copy link
Copy Markdown

Summary

  • --res WxH — force the output to an exact resolution (e.g. 32x32, 16x24) using NEAREST resampling
  • --aspectratio W:H — center-crop the output to a given aspect ratio (e.g. 4:3, 16:9)
  • --res takes precedence when both flags are given
  • 18 unit tests covering parsing, resizing, cropping, centering, and edge cases

Usage

spritegrid input.png --res 32x32 -o sprite.png
spritegrid input.png --aspectratio 4:3 -o cropped.png
spritegrid input.png --res 64x48 --aspectratio 4:3 -o sprite.png  # --res wins

Test plan

  • 53 tests pass (uv run pytest)
  • test_resolution.py covers parse_aspect_ratio, apply_resolution, apply_aspect_ratio

Closes #4

🤖 Generated with Claude Code

--res WxH forces the output to an exact pixel resolution using NEAREST
resampling (pixel-art safe). --aspectratio W:H center-crops the output
to the given aspect ratio. --res takes precedence when both are given.

  spritegrid input.png --res 32x32 -o sprite.png
  spritegrid input.png --aspectratio 4:3 -o cropped.png

Includes 18 unit tests covering parsing, resizing, cropping, and
edge cases (identity, centering, portrait/landscape).

Closes marksverdhei#4

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

Custom aspect ratios and grid sizes.

2 participants