Skip to main content

Change image resolution

How to change resolution using viewport

device_scale param

The device_scale parameter plays a crucial role in determining the pixel density and resolution of the rendered image. Here's a detailed explanation:

  • Type: Number
  • Description: Modifies the pixel density of the screenshot. Higher values result in higher resolution images.
  • Allowed Values:
    • 1: Standard resolution, equivalent to a regular monitor.
    • 2: High resolution, similar to a 4K monitor. This is the default value.
    • 3: Ultra-high resolution, providing the highest level of detail.
  • Usage: Suitable for various scenarios. Use a lower value for faster rendering and less detail, or a higher value for detailed images, ideal for high-quality presentations or print.
import requests

def change_image_resolution():
url = "https://api.canvasflare.com/render?api_key=YOUR_API_KEY"
headers = {
"Content-Type": "application/json",
}
data = {
"html": "<div>High Resolution Image</div>",
"device_scale": 3 # Higher value for higher resolution
}

response = requests.post(url, json=data, headers=headers)
print(response.json())

change_image_resolution()