Skip to content

capture: keep the viewport size on full-page captures - #11

Open
aktanazat wants to merge 1 commit into
brijr:mainfrom
aktanazat:fix/full-page-viewport-height
Open

aktanazat wants to merge 1 commit into
brijr:mainfrom
aktanazat:fix/full-page-viewport-height

Conversation

@aktanazat

Copy link
Copy Markdown

full-page captures resized the viewport to the page height before taking the screenshot, so a 100vh section grew to fill the whole image. on a 320×240 page that starts with a full-height blue header, iris --full came back solid blue and everything under the header was cut off. now the viewport stays at the requested size and the screenshot clips the whole document, still at 2x up to chrome's ~16k px limit and 1x past it.

cargo test full_page_capture_keeps_viewport_relative_heights fails on main (the row right under the header is still blue) and passes with this change. the test reads pixels with the png crate, added as a dev-dependency.

before after
blue 100vh section incorrectly fills the image blue, orange, and green sections keep their layout

Full-page captures resized the viewport to the document height before
taking the screenshot, so a 100vh section grew to fill the whole image
and the rest of the page fell off the bottom. Chromiumoxide's full_page
option, used for pages past the Retina limit, resizes it the same way.

Clip the whole document with captureBeyondViewport instead. The clip
keeps the device scale factor, so full pages stay at 2x up to the
existing ~16k px limit and fall back to 1x past it. Settle every image
in the document before the screenshot, which the resized viewport used
to do implicitly.

Assisted-by: Claude Opus 5.5
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.

1 participant