Repository navigation
fix: place offset GIF frames on the full logical screen - #22
Open
parth-garg01 wants to merge 1 commit into
Open
parth-garg01 wants to merge 1 commit into
parth-garg01 wants to merge 1 commit into
Conversation
A GIF's first frame may cover only part of its logical screen. image/gif returns that frame with its own bounds, so gravity and crops were computed relative to the frame instead of the whole image. Draw the frame onto a canvas the size of the logical screen before analysis.
AutogravityProject ID: Tip HTTPS and SSL certificates are handled automatically for all your Sites |
🟢 Tier S · Ready to merge
Note @parth-garg01 does not have write access to this repository, so Hansi does not approve automatically. A maintainer can review and approve. 📂 Walkthrough · 2
Reviewed |
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.

What does this PR do?
A GIF's first frame can cover only part of the GIF's logical screen.
image/gifreturns that frame with its own bounds (for example(800,0)-(1600,450)on a 1600×450 screen). The rest of the pipeline therefore computed gravity and FocalNet crops relative to the frame, not the whole image.imageutil.Decodenow draws a GIF frame onto a transparent NRGBA canvas the size of the logical screen when the frame's bounds differ from it. The screen size is already checked againstMaxPixels, so the canvas stays within the existing limit. GIFs whose first frame fills the screen, which is the common case, are returned unchanged.Before (main @ 35b155f, 1600×450 GIF with the 800×450
generated-face-left.jpgframe at x=800):After:
For reference, the source JPEG on its own gives
x = 0.2625, and (800 + 0.2625 × 800) / 1600 = 0.631.Test Plan
TestDecodeGIFPlacesOffsetFrameOnCanvas. It fails on main (decoded bounds = (2,0)-(4,2), want the 4x2 logical screen) and passes with this change.test -z "$(gofmt -l cmd internal tools)",go vet ./...,go test -race ./...,go build ./cmd/autogravity: all pass.go test -race -tags=integration ./...withONNXRUNTIME_LIBpointing to ONNX Runtime 1.30.0 (macOS arm64) and the checked-in INT8 and YuNet models: all pass.rose.gif, and malformed GIFs. The output is shown above. Malformed GIFs still return400 invalid image.Related PRs and Issues
Fixes #21
Have you read the Contributing Guidelines on issues?
Yes.
(Everything below is for the main session only.)