Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set page.settings.loadImages = true before page.open(), use the same viewportSize as the page’s CSS, and render only after the background resource and any page-specific asynchronous code have completed. PhantomJS’s page.render() captures the rendered CSS and HTML, so a background-image can appear in PNG or JPEG output without being added as an <img> element. If it is missing, the usual causes are a responsive rule that does not match your viewport, an invalid or inaccessible URL, a timed-out request, or rendering before JavaScript applies the background.

What PhantomJS actually captures

PhantomJS uses a WebKit-based layout and rendering engine. Its screen-capture guide describes screenshots of CSS-styled HTML, SVG, images and Canvas because the page is rendered rather than scraped. The official screen-capture guide shows page.render() as the final capture operation.

A CSS declaration such as background-image: url("/assets/hero.jpg") is therefore part of the rendered result. You do not need to convert it to an <img>. The important distinction is timing: the page.open() callback indicates that navigation completed, but a site may still insert a background, swap a URL, or load it after that callback.

Minimal working PhantomJS script

This script sets the viewport and image loading before navigation, checks the navigation status, then writes a PNG. The filename extension selects the format when no explicit format is supplied; PNG is documented by the render API.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
var page = require('webpage').create();

// Set these before page.open().
page.viewportSize = { width: 1280, height: 800 };
page.settings.loadImages = true;

page.open('https://example.com/', function (status) {
  if (status !== 'success') {
    console.log('Unable to load the page.');
    phantom.exit(1);
    return;
  }

  // Render after the page-specific background is ready.
  page.render('capture.png');
  phantom.exit();
});

loadImages is enabled by default, but setting it explicitly makes the requirement clear. The settings documentation also requires settings to be configured before the initial page.open() call: page settings reference.

Control the viewport and capture region

Match the CSS breakpoint

Responsive styles can use one background at 1280 pixels and another, or none, at 768 pixels. Set page.viewportSize before opening the page and use the width and height that your target media queries expect.

page.viewportSize = { width: 1440, height: 900 };
page.settings.loadImages = true;
page.open('https://example.com/', function (status) {
  if (status === 'success') {
    page.render('desktop.png');
  }
  phantom.exit(status === 'success' ? 0 : 1);
});

Capture only the background area

The screen-capture guide documents clipRect for selecting a rectangular region. Coordinates are in the rendered page, so calculate them for the viewport and page layout you actually use.

page.clipRect = { top: 0, left: 0, width: 1280, height: 500 };
page.render('hero.png');

A clip does not force an image to load; it only limits what is written after rendering.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Wait for the background that your page uses

Static CSS backgrounds

For a background declared in the initial stylesheet, rendering from the successful page.open() callback often works because image loading is on by default. It is not a universal guarantee for every site, however. The official settings and guide pages do not define a fixed delay that is reliable across pages.

JavaScript-generated backgrounds

If application code sets style.backgroundImage, changes a class, or lazy-loads a hero after navigation, wait for a condition that represents that page’s actual state. A polling loop is safer than an arbitrary sleep:

function waitForBackground(selector, callback) {
  var deadline = Date.now() + 10000;
  (function check() {
    var ready = page.evaluate(function (sel) {
      var el = document.querySelector(sel);
      if (!el) return false;
      var value = getComputedStyle(el).backgroundImage;
      return value && value !== 'none';
    }, selector);

    if (ready) return callback(true);
    if (Date.now() >= deadline) return callback(false);
    setTimeout(check, 100);
  }());
}

page.open('https://example.com/', function (status) {
  if (status !== 'success') {
    phantom.exit(1);
    return;
  }
  waitForBackground('.hero', function (ready) {
    if (!ready) {
      console.log('Background was not applied before the deadline.');
      phantom.exit(1);
      return;
    }
    page.render('capture.png');
    phantom.exit();
  });
});

This checks that a CSS value is applied, not that the server returned a valid image. For a stronger page-specific check, expose a JavaScript flag after your application has loaded the asset, or inspect the element’s dimensions and state before calling render().

Diagnose a missing background image

1. Verify the rule and URL

  • Inspect the computed style at the screenshot viewport. A more specific selector, a media query, or an inline rule may override the declaration.
  • Resolve relative URLs from the page’s document URL. A path that works in a stylesheet on one host can fail when the stylesheet is moved or when the page is opened from a different origin.
  • Check the image’s status, redirects and access control. An inaccessible or missing resource cannot appear in the screenshot.

2. Log resource failures and timeouts

PhantomJS exposes resource callbacks and a resourceTimeout setting. Use them to distinguish a slow request from a CSS problem:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.
page.settings.loadImages = true;
page.settings.resourceTimeout = 15000;

page.onResourceError = function (error) {
  console.log('Resource error: ' + error.errorString + ' ' + error.url);
};
page.onResourceTimeout = function (request) {
  console.log('Resource timeout: ' + request.url);
};

page.open('https://example.com/', function (status) {
  console.log('Navigation: ' + status);
  if (status === 'success') page.render('capture.png');
  phantom.exit(status === 'success' ? 0 : 1);
});

The exact callback fields can vary with the PhantomJS build, so log the object while diagnosing. Increasing the timeout only helps a resource that is eventually reachable; it cannot repair a bad URL or blocked request.

3. Check whether the image is intentionally hidden

Transparent backgrounds, display:none, zero-height containers, overlays, and a foreground element with an opaque fill can make a loaded background appear absent. Inspect the computed background-image, background-size, background-position, opacity, and element box in page.evaluate().

Output format and image quality

Use a .png filename when preserving text, sharp edges, or transparency matters. Use a .jpg filename for a photographic result where lossy compression is acceptable. The render API documents PNG and JPEG, and says the extension normally determines the output format. Changing format cannot fix a missing CSS request or an early render.

Reliability limits you should plan for

PhantomJS’s official home page states: “PhantomJS development is suspended until further notice.” It uses QtWebKit and does not claim a modern browser compatibility target: PhantomJS project home page. Older WebKit behavior can differ from current Chromium-based browsers, especially for newer CSS, JavaScript, TLS and site defenses. If a page depends on features PhantomJS does not implement, no wait loop will make that feature render correctly.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

For repeatable captures, pin the PhantomJS binary, set the viewport explicitly, keep loadImages enabled, define a page-specific readiness condition, record resource errors, and fail the job when the condition is not met. Do not claim that a generic 500-millisecond or five-second delay works for every site.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server for developers. A single GET request returns PNG, JPEG, WebP or PDF. It handles consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; each step can be disabled. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers report the page verdict and whether the shot was billed.

For a direct capture, see the ScreenshotNeo documentation and run:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The API also supports full-page shots with lazy images loaded, element capture by CSS selector, custom viewport and device presets, retina scale, dark mode, PDF controls, custom CSS and JavaScript, clicks, selector or network-idle waits, blocked resources, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed links, asynchronous webhooks, bulk capture of up to 100 URLs per call, a usage API and an OpenAPI specification. Parameter names used by other screenshot APIs are accepted to ease migration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

An MCP server provides take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients. Every feature is included on every plan: 1,000 screenshots per month are free with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Common failure symptoms and fixes

Symptom Likely cause Fix
Background is missing at one width Responsive rule does not match Set viewportSize before open() and inspect computed style.
Solid color appears instead Image request failed or timed out Verify the URL; log resource errors; set a suitable resourceTimeout.
First capture is blank, later refresh works Background is applied asynchronously Wait for a selector, computed style, or application-ready flag.
Modern page layout is broken PhantomJS’s suspended, older WebKit engine Use a page compatible with that engine or move capture to a maintained browser/API.

FAQ

Does loadImages need to be enabled?

It is enabled by default, but set it before page.open() so the script’s intent is explicit.

Can clipRect capture a background that is outside the viewport?

It selects a rendered rectangle; it does not scroll or load content outside the rendered page. Arrange the page and viewport first.

Should I always use PNG?

Use PNG for lossless detail or transparency and JPEG when lossy photographic compression is acceptable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.