Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk3 min

How to Capture a Website Screenshot with PhantomJS on Ubuntu

Use a small PhantomJS script to open a webpage, check its load status, and save a screenshot from Ubuntu's terminal. Includes output settings and legacy-tool caveats.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To capture a webpage with PhantomJS on Ubuntu, save a short JavaScript file that opens the URL, checks the load status, and calls page.render(); then run it with phantomjs screenshot.js. The resulting image is written to the directory from which you ran the command. PhantomJS is a legacy tool: its repository is archived and development is suspended, and package availability depends on your Ubuntu release.

Capture a webpage with PhantomJS

PhantomJS is a command-line tool that runs a JavaScript file; it does not provide a screenshot GUI. The official quick start uses this same script-and-command pattern: PhantomJS Quick Start.

As an Amazon Associate I earn from qualifying purchases.

  1. Create a file named screenshot.js containing:

    var page = require('webpage').create();
    page.open('https://example.com', function(status) {
      if (status === 'success') {
        page.render('screenshot.png');
      } else {
        console.log('Unable to load the page.');
      }
      phantom.exit();
    });
  2. In a terminal, change to the directory containing screenshot.js, then run:

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    phantomjs screenshot.js
  3. When loading succeeds, find screenshot.png in the current working directory—the directory where you ran the command. The quick start documents this output location.

    #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

The page.open() callback receives a status of success or fail. This script renders only on success and calls phantom.exit() after either outcome so the process terminates. See the page.open API.

Choose the captured dimensions and format

Set the viewport or crop the output

To set the browser layout size, assign page.viewportSize before opening the URL. To render only a rectangle, set page.clipRect. For example, add these lines after creating the page and before page.open():

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
page.viewportSize = { width: 1280, height: 800 };
page.clipRect = { top: 0, left: 0, width: 1280, height: 800 };

The viewport controls the headless browser’s layout area; the clip rectangle selects the rendered region. The screen-capture guide demonstrates both settings.

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.

Select an image format

Use a filename extension such as .png or .jpg; PhantomJS normally determines the render format from that extension. The render API lists PDF, PNG, JPEG, BMP, and PPM, with GIF support dependent on the Qt build. JPEG quality is an integer from 0 to 100 and defaults to 75; PNG’s quality option controls compression, not visible image quality. Details are in the render API.

Rank #3
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.

If the image background appears transparent, the page may not set a background color. The PhantomJS FAQ notes that a page with no background set may remain transparent and suggests setting a white body background with page script when that suits the page.

Check whether PhantomJS is available on your Ubuntu release

Do not assume PhantomJS can be installed from the default repositories on every Ubuntu version. The package evidence cited here is specific to Ubuntu Focal: its manpage records version 2.1.1+dfsg-2ubuntu1. Check package availability for your own Ubuntu release, then verify an installed binary with:

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • 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
phantomjs --version

The PhantomJS GitHub repository was archived by its owner on May 30, 2023. Its README states, “Important: PhantomJS development is suspended until further notice.” The Ubuntu Focal manpage documents the Focal package, not availability on other releases. Legacy prebuilt binaries and compatibility can vary.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common capture problems

Or skip the browser setup

ScreenshotNeo can return a webpage screenshot with one GET request. Cookie banners are accepted and removed before capture, along with known consent platforms, newsletter popups, and chat widgets. Bot checks, blank pages, and failed loads are never billed; the response identifies the page verdict and billing status. Its MCP server lets AI agents take screenshots, and 1,000 screenshots a month are free with no card; paid plans start at $5 for 3,000.

Example cURL request:

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

See the ScreenshotNeo documentation for request options. Sign up for 1,000 free screenshots a month with no card.

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.

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

Leave a Reply

Your email address will not be published. Required fields are marked *

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.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.