Repository navigation
ritmo-tools pixel: read the grid on the subject, and never call an upscale 1x art - #226
Merged
Merged
Conversation
…scale 1x art detectGrid now finds the cell size on the picture's subject (its visible pixels, or the pixels away from a uniform border color, with a 4 px margin) and places the grid back on the whole picture. An empty canvas around a small sprite made every cell size look clean. isNative no longer takes a smooth picture with many colors (an upscale whose grid was not found) as pixel art at its own size, so check reports needs-person instead of clean at the picture's full size. Measured with xprite-pixelate's benchmark and pixel-bench v1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes to
pixel check/pixel fixgrid detection, found by scoring the fixer on xprite-pixelate's benchmark (MIT) and pixel-bench v1 (MIT), throughcheckImage, the path the CLI runs.What changes
detectGridingrid.ts). It finds the box holding the subject: its visible pixels, or, on an opaque picture whose border is one color, the pixels away from that color. It keeps a 4 px margin, so the outline stays where the edge profiles see it. It detects there, then shifts the offsets back onto the whole picture. Output size and recipes are unchanged.isNativeinreport.ts). If under 5% of neighbouring pixels change color and the picture has more than 32 colors, it is judged as a fix. A grid that can't be found now reportsneeds-personinstead ofcleanat full size. The color limit keeps flat parallax layers counted as 1× art.Evidence (exact size)
fixable/clean)Rows for this PR use the crop as measured before the 4 px margin was added. On a 722-case sample, the margin moved exact sizes by under a point.
Real 1× art: 165 of 178 corpus images were left alone before and 170 after. 280 shipped PNGs from Still Time, Landkeep and Spirit Call give identical verdicts. The crop measured alone won 211 AI cases and lost 15.
Known limits
clean.needs-person, never a bad fix.Tests
pnpm run checkpasses. No public TypeScript API changed, so no website build.🤖 Generated with Claude Code