render: PNG screenshots via CLI and CDP
End-to-end rasterization behind the render feature (which now enables obscura-render/paint): - obscura-render: screenshot_png(dom, viewport) paints and encodes to PNG via tiny-skia's encode_png (no extra dep). - obscura-browser: Page::screenshot renders the live DOM at a viewport. - CLI: obscura fetch --screenshot out.png writes the settled page to a PNG. - CDP: Page.captureScreenshot returns the PNG base64-encoded, so Puppeteer/Playwright page.screenshot() works. captureSnapshot still errors (it is a DOM/layer snapshot, not an image). Verified: both paths produce correct 1280x720 RGBA PNGs with elements laid out and colored as the CSS specifies (block stacking, backgrounds, white page). Default build unchanged; obstacle course 33/33. Text, borders, and images are not yet painted; the box layout and background colors are rendered.
This commit is contained in:
1 parent
4ca85e87d8
commit
cdd52ade43
9 files changed
+92
-12
No files matched your search
@@ -10,9 +10,9 @@ default = []
|
||||
# TLS fingerprint and client hints as stealth navigation.
|
||||
stealth = ["obscura-net/stealth"]
|
||||
# Builds the obscura-render layout layer and exposes real box geometry to JS
|
||||
# (getBoundingClientRect, elementFromPoint, offset*). Off by default so the
|
||||
# scraping build stays lean; the cache is feature-gated and absent otherwise.
|
||||
render = ["dep:obscura-render"]
|
||||
# (getBoundingClientRect, elementFromPoint, offset*), and with paint enabled,
|
||||
# rasterizes screenshots. Off by default so the scraping build stays lean.
|
||||
render = ["dep:obscura-render", "obscura-render/paint"]
|
||||
|
||||
[build-dependencies]
|
||||
deno_core = "0.350"
|
||||
|
||||
@@ -10,3 +10,8 @@ pub mod markdown;
|
||||
|
||||
pub use markdown::HTML_TO_MARKDOWN_JS;
|
||||
pub use v8_flags::set_v8_flags;
|
||||
|
||||
// Screenshot rasterization (PNG bytes) from the render layer. Available when the
|
||||
// render feature (which enables obscura-render/paint) is compiled in.
|
||||
#[cfg(feature = "render")]
|
||||
pub use obscura_render::screenshot_png;
|
||||
Reference in new issue
Block a user