Skip to content

Guide

Capture a long page as a phone sees it

A narrow window is not a phone. Use the mobile preset for the layout a phone gets, then keep the output a size you can store and open.

Setting width to 390 gets the media queries right, but the page still sees a desktop browser: no touch, a desktop user agent and a density of 1. Sites that serve different markup or images to phones show their desktop version squeezed into a narrow window.

Use the mobile preset

device: "mobile" sets a 390 by 844 viewport, a device pixel ratio of 3, touch and a phone user agent together. An explicit width, height or device_scale_factor still wins, which is how the request below keeps the phone layout at a density of 2.

curl -sS https://api.ironfang.com/render/v1/screenshot \
  -H "Authorization: Bearer $IRONFANG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://ironfang.com/company",
    "device": "mobile",
    "device_scale_factor": 2,
    "full_page": true,
    "full_page_readiness": "scroll",
    "format": "jpeg",
    "quality": 80
  }' \
  -o company-mobile.jpg
The top of the Ironfang company page as captured on a phone: the logo and menu button, the heading We build the infrastructure developers should not have to, and the start of the next section.
The first two screens of that capture. The whole image is 780 by 9,922 pixels.

Keep the output a usable size

The image is the page height times the density. At the preset density of 3, a page 19,070 CSS pixels tall comes back 57,210 pixels tall, which many image viewers and upload limits refuse. For archives and review, a density of 1 or 2 is usually enough.

WebP cannot hold an image taller than 16,383 pixels, so use JPEG or PNG for long captures. JPEG keeps a tall capture small; PNG is lossless.

Cap pages with no natural end

A feed that keeps loading has no bottom. full_page_max_height cuts the capture at a height in CSS pixels, 20,000 at most and by default, and the X-Ironfang-Warnings header says height_capped when it does.

{
  "url": "https://example.com/feed",
  "device": "mobile",
  "full_page": true,
  "full_page_max_height": 8000,
  "format": "jpeg"
}

Sticky headers and fixed bars

The capture is taken from the top, so a sticky header appears once, at the top, and a fixed bar sits where it was in the first screen. Hide either with hide_selectors, and consent banners with block_cookie_banners.

Next