Skip to main content

Viewport Configuration

The viewport defines the visible area of the web page that will be captured in your screenshot. Properly configuring the viewport is crucial for capturing web pages exactly as they appear on different devices and screen sizes.

Viewport Parameters

Width (vw)

  • Default: 1440 pixels
  • Description: Sets the viewport width in pixels
  • Range: Any positive integer value
  • Example: vw=1920 for Full HD width

Height (vh)

  • Default: 900 pixels
  • Description: Sets the viewport height in pixels
  • Range: Any positive integer value
  • Example: vh=1080 for Full HD height

Scale Factor (scaleFactor)

  • Default: 1
  • Description: Device pixel ratio (DPR) that affects the pixel density
  • Range: Typically between 1 and 3
  • Common Values:
    • 1 - Standard resolution (non-retina)
    • 2 - High resolution (retina displays)
    • 3 - Ultra-high resolution (modern mobile devices)

Usage Examples

Standard Desktop Screenshot

https://cdn.capture.page/YOUR_API_KEY/HASH/image?url=https://example.com&vw=1920&vh=1080

Mobile-sized Screenshot

https://cdn.capture.page/YOUR_API_KEY/HASH/image?url=https://example.com&vw=375&vh=667

High-DPI Screenshot

https://cdn.capture.page/YOUR_API_KEY/HASH/image?url=https://example.com&vw=1440&vh=900&scaleFactor=2

Common Viewport Sizes

Desktop Resolutions

ResolutionWidthHeightUse Case
HD1366768Most common laptop resolution
Full HD19201080Standard desktop monitor
2K25601440High-end monitors
4K38402160Ultra HD displays

Mobile Resolutions

Device TypeWidthHeightScale Factor
iPhone SE3756672
iPhone 143908443
iPhone 14 Plus4289263
Pixel 53938512.75
Samsung Galaxy S213608003

Tablet Resolutions

Device TypeWidthHeightScale Factor
iPad Mini76810242
iPad Air82011802
iPad Pro 11"83411942
iPad Pro 12.9"102413662

Best Practices

1. Match Target Audience

Choose viewport dimensions that match your target audience's most common devices. Use analytics data to determine the most popular screen sizes among your users.

2. Consider Responsive Breakpoints

Test your website at common responsive design breakpoints:

  • Mobile: 320-768px
  • Tablet: 768-1024px
  • Desktop: 1024px and above

3. Scale Factor Considerations

  • Use scaleFactor=1 for faster processing and smaller file sizes
  • Use scaleFactor=2 or higher for crisp, high-quality screenshots
  • Higher scale factors increase processing time and file size

4. Viewport vs Full Page

Remember that viewport settings only affect the visible area. To capture the entire page height, use the full=true parameter along with your viewport settings.

Advanced Tips

Testing Responsive Design

Create multiple screenshots at different viewport sizes to test responsive behavior:

const viewports = [
{ width: 320, height: 568 }, // Mobile
{ width: 768, height: 1024 }, // Tablet
{ width: 1920, height: 1080 } // Desktop
];

viewports.forEach(vp => {
const url = `https://cdn.capture.page/KEY/HASH/image?url=site.com&vw=${vp.width}&vh=${vp.height}`;
// Generate screenshot URL
});

Simulating Device Pixel Ratios

To accurately simulate how your site appears on high-DPI displays:

// Standard display
&vw=1920&vh=1080&scaleFactor=1

// Retina display
&vw=1920&vh=1080&scaleFactor=2

// Mobile with high DPI
&vw=375&vh=667&scaleFactor=3

Relationship with Other Options

  • Device Emulation: When using emulateDevice, viewport settings are automatically configured
  • Full Page Capture: Viewport width affects the layout when using full=true
  • Clipping: Viewport defines the default capture area when no clipping is specified

Performance Considerations

  • Larger viewports require more memory and processing time
  • High scale factors multiply the effective resolution (e.g., 1920x1080 at scale 2 = 3840x2160 pixels)
  • Consider using smaller viewports with clipping for specific page sections

See Also