Skip to content

[Bug]: Screenshot size does not correspond Crawler and Browser settings #1750

@dteran-godaddy

Description

@dteran-godaddy

crawl4ai version

0.8.0

Expected Behavior

When taking screenshot with defined viewport (1920x1080), scan_full_page=False and adjust_viewport_to_content=False, I expect the screenshot size to be 1920x1080

Current Behavior

When taking screenshot, after decoding it from base64 it's:
file.png: PC bitmap, Windows 3.x format, 4114 x 6064 x 24, image size 74854016, resolution 3780 x 3780 px/m, cbSize 74854070, bits offset 54

Is this reproducible?

Yes

Inputs Causing the Bug

URL: physio-tiere.de
Settings:

            "crawler_config": {
                "adjust_viewport_to_content": false,
                "bypass_cache": false,
                "cache_mode": "<CacheMode.WRITE_ONLY: 'write_only'>",
                "capture_console_messages": true,
                "capture_mhtml": false,
                "capture_network_requests": false,
                "check_robots_txt": false,
                "chunking_strategy": "<crawl4ai.chunking_strategy.RegexChunking object at 0x75697cfd2990>",
                "css_selector": null,
                "deep_crawl_strategy": null,
                "delay_before_return_html": 2,
                "disable_cache": false,
                "exclude_all_images": false,
                "exclude_domains": [],
                "exclude_external_images": true,
                "exclude_external_links": false,
                "exclude_internal_links": false,
                "exclude_social_media_domains": [
                    "facebook.com",
                    "twitter.com",
                    "x.com",
                    "linkedin.com",
                    "instagram.com",
                    "pinterest.com",
                    "tiktok.com",
                    "snapchat.com",
                    "reddit.com"
                ],
                "exclude_social_media_links": false,
                "excluded_selector": "",
                "excluded_tags": [],
                "experimental": {},
                "extraction_strategy": null,
                "fetch_ssl_certificate": false,
                "geolocation": null,
                "ignore_body_visibility": true,
                "image_description_min_word_threshold": 0,
                "image_score_threshold": 0,
                "js_code": null,
                "js_only": false,
                "keep_attrs": [],
                "keep_data_attributes": false,
                "link_preview_config": null,
                "locale": null,
                "log_console": false,
                "magic": true,
                "markdown_generator": null,
                "match_mode": "<MatchMode.OR: 'or'>",
                "max_range": 0.3,
                "max_scroll_steps": null,
                "mean_delay": 0.1,
                "method": "GET",
                "no_cache_read": false,
                "no_cache_write": false,
                "only_text": false,
                "override_navigator": true,
                "page_timeout": 120000,
                "parser_type": "lxml",
                "pdf": false,
                "prefetch": false,
                "preserve_https_for_internal_links": false,
                "prettiify": false,
                "process_iframes": false,
                "process_in_browser": false,
                "proxy_config": null,
                "proxy_rotation_strategy": null,
                "proxy_session_auto_release": false,
                "proxy_session_id": null,
                "proxy_session_ttl": null,
                "remove_forms": false,
                "remove_overlay_elements": true,
                "scan_full_page": false,
                "score_links": false,
                "scraping_strategy": "<crawl4ai.content_scraping_strategy.LXMLWebScrapingStrategy object at 0x75697bc68440>",
                "screenshot": true,
                "screenshot_height_threshold": 50,
                "screenshot_wait_for": null,
                "scroll_delay": 0.2,
                "semaphore_count": 5,
                "session_id": null,
                "shared_data": null,
                "simulate_user": true,
                "stream": false,
                "table_extraction": "<crawl4ai.table_extraction.DefaultTableExtraction object at 0x756989da89e0>",
                "table_score_threshold": 7,
                "target_elements": [],
                "timezone_id": null,
                "url": null,
                "url_matcher": null,
                "user_agent": null,
                "user_agent_generator_config": {},
                "user_agent_mode": null,
                "verbose": false,
                "wait_for": null,
                "wait_for_images": false,
                "wait_for_timeout": null,
                "wait_until": "domcontentloaded",
                "word_count_threshold": 1
            }
        },


            "browser_config": {
                "accept_downloads": false,
                "browser_context_id": null,
                "browser_mode": "dedicated",
                "browser_type": "chromium",
                "cdp_cleanup_on_close": false,
                "cdp_url": null,
                "channel": "chromium",
                "chrome_channel": "chromium",
                "cookies": [],
                "create_isolated_context": false,
                "debugging_port": 9222,
                "downloads_path": null,
                "enable_stealth": false,
                "extra_args": [
                    "--disable-http-cache",
                    "--disable-gpu",
                    "--hide-scrollbars",
                    "--autoplay-policy=user-gesture-required",
                    "--no-first-run",
                    "--enable-automation",
                    "--disable-background-timer-throttling",
                    "--disable-notifications",
                    "--disable-features=TranslateUI",
                    "--disable-dev-shm-usage",
                    "--disable-web-security",
                    "--disable-features=HttpsUpgrades",
                    "--host-resolver-rules="
                ],
                "headers": {
                    "sec-ch-ua": "\"Safari\";v=\"18\", \"Not_A Brand\";v=\"8\""
                },
                "headless": true,
                "host": "localhost",
                "ignore_https_errors": true,
                "init_scripts": [],
                "java_script_enabled": true,
                "light_mode": false,
                "proxy": null,
                "proxy_config": null,
                "sleep_on_close": false,
                "storage_state": null,
                "target_id": null,
                "text_mode": false,
                "use_managed_browser": false,
                "use_persistent_context": false,
                "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3.1 Safari/605.1.15",
                "user_agent_generator_config": {},
                "user_agent_mode": "",
                "user_data_dir": null,
                "verbose": true,
                "viewport_height": 1080,
                "viewport_width": 1920
            },

Steps to Reproduce

1. Try crawling the provided URL with screenshot=True

Code snippets

OS

Ubuntu 24.04.3 LTS

Python version

3.12.3

Browser

Chromium

Browser version

No response

Error logs & Screenshots (if applicable)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 BugSomething isn't working🩺 Needs TriageNeeds attention of maintainers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions