{"id":13494155,"url":"https://github.com/vgalin/html2image","last_synced_at":"2026-07-19T21:46:01.646Z","repository":{"id":37100880,"uuid":"282500233","full_name":"vgalin/html2image","owner":"vgalin","description":"A package acting as a wrapper around the headless mode of existing web browsers to generate images from URLs and from HTML+CSS strings or files.","archived":false,"fork":false,"pushed_at":"2026-03-22T20:05:34.000Z","size":1046,"stargazers_count":453,"open_issues_count":38,"forks_count":49,"subscribers_count":4,"default_branch":"master","last_synced_at":"2026-05-29T12:14:30.742Z","etag":null,"topics":["chrome","chromium","chromium-browser","css","headless-browser","html","html2image","python","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vgalin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"vgalin","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2020-07-25T18:15:51.000Z","updated_at":"2026-05-15T18:30:48.000Z","dependencies_parsed_at":"2023-12-22T14:32:34.338Z","dependency_job_id":"157de210-675d-4b50-8ab5-34f220c8c38b","html_url":"https://github.com/vgalin/html2image","commit_stats":{"total_commits":148,"total_committers":8,"mean_commits":18.5,"dds":0.08783783783783783,"last_synced_commit":"9e9fcf2d0d80b415aa2041cbdd7c1aa0f49aa74f"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/vgalin/html2image","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgalin%2Fhtml2image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgalin%2Fhtml2image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgalin%2Fhtml2image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgalin%2Fhtml2image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vgalin","download_url":"https://codeload.github.com/vgalin/html2image/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgalin%2Fhtml2image/sbom","scorecard":{"id":919554,"data":{"date":"2025-08-11","repo":{"name":"github.com/vgalin/html2image","commit":"81c0609f57c1b604485a39d23fb4e0b211015745"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.6,"checks":[{"name":"Code-Review","score":5,"reason":"Found 6/12 approved changesets -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/main.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Pinned-Dependencies","score":1,"reason":"dependency not pinned by hash detected -- score normalized to 1","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:59: update your workflow using https://app.stepsecurity.io/secureworkflow/vgalin/html2image/main.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:62: update your workflow using https://app.stepsecurity.io/secureworkflow/vgalin/html2image/main.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:67: update your workflow using https://app.stepsecurity.io/secureworkflow/vgalin/html2image/main.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:82: update your workflow using https://app.stepsecurity.io/secureworkflow/vgalin/html2image/main.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/vgalin/html2image/main.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/vgalin/html2image/main.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/vgalin/html2image/main.yml/master?enable=pin","Warn: containerImage not pinned by hash: Dockerfile:1: pin your Docker image by updating python to python@sha256:3b2f1b9c9948e9dc96e1a2f4668ba9870ff43ab834f91155697476142b3bc299","Warn: downloadThenRun not pinned by hash: Dockerfile:3","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 third-party GitHubAction dependencies pinned","Info:   0 out of   1 containerImage dependencies pinned","Info:   0 out of   1 downloadThenRun dependencies pinned","Info:   1 out of   1 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact 2.0.5 not signed: https://api.github.com/repos/vgalin/html2image/releases/174224748","Warn: release artifact 2.0.4.3 not signed: https://api.github.com/repos/vgalin/html2image/releases/117459992","Warn: release artifact 2.0.4 not signed: https://api.github.com/repos/vgalin/html2image/releases/117244342","Warn: release artifact 2.0.5 does not have provenance: https://api.github.com/repos/vgalin/html2image/releases/174224748","Warn: release artifact 2.0.4.3 does not have provenance: https://api.github.com/repos/vgalin/html2image/releases/117459992","Warn: release artifact 2.0.4 does not have provenance: https://api.github.com/repos/vgalin/html2image/releases/117244342"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 28 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-25T00:26:46.035Z","repository_id":37100880,"created_at":"2025-08-25T00:26:46.035Z","updated_at":"2025-08-25T00:26:46.035Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35666469,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-19T02:00:06.923Z","response_time":112,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrome","chromium","chromium-browser","css","headless-browser","html","html2image","python","python3"],"created_at":"2024-07-31T19:01:22.394Z","updated_at":"2026-07-19T21:46:01.640Z","avatar_url":"https://github.com/vgalin.png","language":"Python","funding_links":["https://github.com/sponsors/vgalin"],"categories":["Python"],"sub_categories":[],"readme":"\r\n\r\n\r\n\u003ch1 align=\"center\"\u003e\r\n  \u003ca href=\"https://github.com/vgalin/html2image\"\u003e\r\n    \u003cimg src=\"https://raw.githubusercontent.com/vgalin/html2image/master/readme_assets/html2image_black.png\" alt=\"html2image logo\" title=\"html2image\" height=\"200\"/\u003e\r\n  \u003c/a\u003e\r\n\u003c/h1\u003e\r\n\r\n\r\n\u003cdiv align=\"center\"\u003e\r\n\r\n![PyPI](https://img.shields.io/pypi/v/html2image.svg)\r\n![PyPI](https://img.shields.io/pypi/pyversions/html2image.svg)\r\n![PyPI](https://img.shields.io/github/license/vgalin/html2image.svg)\r\n![GitHub](https://img.shields.io/github/v/release/vgalin/html2image?include_prereleases)\r\n![GitHub](https://img.shields.io/github/languages/code-size/vgalin/html2image)\r\n\r\n\r\n|[PyPI Package](https://pypi.org/project/html2image/)|[GitHub Repository](https://github.com/vgalin/html2image)|\r\n|-|-|\r\n\r\n**A lightweight Python package acting as wrapper around the headless mode of existing web browsers, allowing image generation from HTML/CSS strings, files and URLs.**\r\n\r\n\u003c/div\u003e\r\n\u0026nbsp;\r\n\r\nThis package has been tested on Windows, Ubuntu (desktop and server) and MacOS. If you encounter any problems or difficulties while using it, feel free to open an issue on the GitHub page of this project. Feedback is also welcome!\r\n\r\n⚠️ Disclaimer: Use this package with trusted content only. Processing untrusted or unsanitized input can lead to malicious code execution. Always ensure content safety.\r\n\r\n## Principle\r\n\r\n\r\nMost web browsers have a Headless Mode, which is a way to run them without displaying any graphical interface. Headless mode is mainly used for automated testing but also comes in handy if you want to take screenshots of web pages that are exact replicas of what you would see on your screen if you were using the browser yourself.\r\n\r\nHowever, for the sake of taking screenshots, headless mode is not very convenient to use. HTML2Image aims to hide the inconveniences of the browsers' headless modes while adding useful features, such as allowing the creation of images from simple strings.\r\n\r\nFor more information about headless modes :\r\n-   (Chrome) [https://developers.google.com/web/updates/2017/04/headless-chrome](https://developers.google.com/web/updates/2017/04/headless-chrome)\r\n-   (Firefox) [https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode](https://web.archive.org/web/20210604151145/https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode)\r\n\r\n## Installation\r\nHTML2Image is published on PyPI and can be installed through `pip`:\r\n\r\n```console\r\npip install --upgrade html2image\r\n```\r\n\r\nOr with `uv`:\r\n```console\r\nuv pip install html2image\r\n```\r\n\r\nIn addition to this package, at least one of the following browsers **must** be installed on your machine :\r\n-   Google Chrome (Windows, MacOS)\r\n-   Chromium Browser (Linux)\r\n-   Microsoft Edge\r\n\r\n## Usage\r\n\r\n### First, import the package and instantiate it\r\n```python\r\nfrom html2image import Html2Image\r\nhti = Html2Image()\r\n```\r\n\r\nMultiple arguments can be passed to the constructor:\r\n\r\n-   `browser` :  Browser that will be used, can be set to `'chrome'` (default) or `'edge'`.\r\n-   `browser_executable` : The path or the command that can be used to find the executable of a specific browser.\r\n-   `output_path` : Path to the folder to which taken screenshots will be outputted. Default is the current working directory of your python program.\r\n-   `size` : 2-Tuple representing the size of the screenshots that will be taken. Default value is `(1920, 1080)`.\r\n-   `temp_path` : Path that will be used to put together different resources when screenshotting strings of files. Default value is `%TEMP%/html2image` on Windows, and `/tmp/html2image` on Linux and MacOS.\r\n-   `keep_temp_files` : Pass True to this argument to not automatically remove temporary files created in `temp_path`. Default is False.\r\n\r\nExample:\r\n```python\r\nhti = Html2Image(size=(500, 200))\r\n```\r\n\r\nYou can also change these values later: \r\n``` python\r\nhti.size = (500, 200)\r\n```\r\n\r\n### Then take a screenshot\r\n\r\nThe `screenshot` method is the basis of this package. Most of the time, you won't need to use anything else. It can take screenshots of various things:\r\n- URLs via the `url` parameter;\r\n- HTML and CSS **files** via the `html_file` and `css_file` parameters;\r\n- HTML and CSS **strings** via the `html_str` and `css_str` parameters;\r\n- and \"other\" types of files via the `other_file` parameter (try it with .svg files!).\r\n\r\nAnd you can also (optional):\r\n- Change the size of the screenshots using the `size` parameter;\r\n- Save the screenshots as a specific name using the `save_as` parameter.\r\n\r\n*N.B.: The `screenshot` method returns a **list** containing the path(s) of the screenshot(s) it took.*\r\n\r\n### A few examples\r\n\r\n- **URL to image**\r\n```python\r\nhti.screenshot(url='https://www.python.org', save_as='python_org.png')\r\n```\r\n\r\n- **HTML \u0026 CSS strings to image**\r\n```python\r\nhtml = \"\"\"\u003ch1\u003e An interesting title \u003c/h1\u003e This page will be red\"\"\"\r\ncss = \"body {background: red;}\"\r\n\r\nhti.screenshot(html_str=html, css_str=css, save_as='red_page.png')\r\n```\r\n\r\n- **HTML \u0026 CSS files to image**\r\n```python\r\nhti.screenshot(\r\n    html_file='blue_page.html', css_file='blue_background.css',\r\n    save_as='blue_page.png'\r\n)\r\n```\r\n\r\n- **Other files to image**\r\n```python\r\nhti.screenshot(other_file='star.svg')\r\n```\r\n\r\n- **Change the screenshots' size**\r\n```python\r\nhti.screenshot(other_file='star.svg', size=(500, 500))\r\n```\r\n\r\n---\r\n\r\n\u003cdetails\u003e\r\n\u003csummary\u003e Click to show all the images generated with all the code above \u003c/summary\u003e\r\n\u003cimg src=\"readme_assets/sample_url_to_img.png\" alt=\"sample_url_to_img.png\"/\u003e\r\n\u003cimg src=\"readme_assets/sample_strings_to_img.png\" alt=\"sample_strings_to_img\"/\u003e\r\n\u003cimg src=\"readme_assets/sample_files_to_img.png\" alt=\"sample_files_to_img\"/\u003e\r\n\u003cimg src=\"readme_assets/sample_other.png\" alt=\"sample_other_to_img\"/\u003e\r\n\u003cimg src=\"readme_assets/sample_other_50_50.png\" alt=\"sample_other_50_50\"/\u003e\r\n\r\n\u003c/details\u003e\r\n\r\n\r\n---\r\n\r\n- **Change the directory to which the screenshots are saved**\r\n```python\r\nhti = Html2Image(output_path='my_screenshot_folder')\r\n```\r\n**OR**\r\n```python\r\nhti.output_path = 'my_screenshot_folder'\r\n```\r\n\r\n*N.B. : the output path will be changed for all future screenshots.*\r\n\r\n---\r\n\r\n#### Use lists in place of any parameters while using the `screenshot` method\r\n- Screenshot multiple objects using only one filename, or one filename per file:\r\n```python\r\n# create three files from one filename\r\nhti.screenshot(html_str=['A', 'B', 'C'], save_as='ABC.png')\r\n# outputs ABC_0.png, ABC_1.png, ABC_2.png\r\n\r\n# create three files from from different filenames\r\nhti.screenshot(html_str=['A', 'B', 'C'], save_as=['A.png', 'B.png', 'C.png'])\r\n# outputs A.png, B.png, C.png\r\n```\r\n- Take multiple screenshots with the same size\r\n```python\r\n# take four screenshots with a resolution of 100*50\r\nhti.screenshot(\r\n    html_str=['A', 'B', 'C', 'D'],\r\n    size=(100, 50)\r\n)\r\n```\r\n- Take multiple screenshots with different sizes\r\n```python\r\n# take four screenshots with different resolutions from three given sizes\r\nhti.screenshot(\r\n    html_str=['A', 'B', 'C', 'D'],\r\n    size=[(100, 50), (100, 100), (50, 50)]\r\n)\r\n# respectively 100*50, 100*100, 50*50, 50*50\r\n# if not enough sizes are given, the last size in the list will be repeated\r\n\r\n```\r\n\r\n- Apply CSS string(s) to multiple HTML string(s)\r\n```python\r\n# screenshot two html strings and apply css strings on both\r\nhti.screenshot(\r\n    html_str=['A', 'B'],\r\n    css_str='body {background: red;}'\r\n)\r\n\r\n# screenshot two html strings and apply multiple css strings on both\r\nhti.screenshot(\r\n    html_str=['A', 'B'],\r\n    css_str=['body {background: red;}', 'body {font-size: 50px;}']\r\n)\r\n\r\n# screenshot one html string and apply multiple css strings on it\r\nhti.screenshot(\r\n    html_str='A',\r\n    css_str=['body {background: red;}', 'body {font-size: 50px;}']\r\n)\r\n```\r\n\r\n---\r\n\r\n- **Retrieve the path of the generated file(s)**  \r\nThe `screenshot` method returns a list containing the path(s) of the screenshot(s):\r\n\r\n```python\r\npaths = hti.screenshot(\r\n    html_str=['A', 'B', 'C'],\r\n    save_as=\"letters.png\",\r\n)\r\n\r\nprint(paths)\r\n# \u003e\u003e\u003e ['D:\\\\myFiles\\\\letters_0.png', 'D:\\\\myFiles\\\\letters_1.png', 'D:\\\\myFiles\\\\letters_2.png']\r\n```\r\n\r\n---\r\n\r\n#### Change browser flags\r\nIn some cases, you may need to change the *flags* that are used to run the headless mode of a browser.\r\n\r\nFlags can be used to:\r\n- Change the default background color of the pages;\r\n- Hide the scrollbar;\r\n- Add delay before taking a screenshot;\r\n- Allow you to use Html2Image when you're root, as you will have to specify the `--no-sandbox` flag;\r\n\r\nYou can find the full list of Chrome / Chromium flags [here](https://peter.sh/experiments/chromium-command-line-switches/).\r\n\r\nThere are two ways to specify custom flags:\r\n```python\r\n# At the object instanciation\r\nhti = Html2image(custom_flags=['--my_flag', '--my_other_flag=value'])\r\n\r\n# Afterwards\r\nhti.browser.flags = ['--my_flag', '--my_other_flag=value']\r\n```\r\n\r\n- **Flags example use-case: adding a delay before taking a screenshot**\r\n\r\nWith Chrome / Chromium, screenshots are fired directly after there is no more \"pending network fetches\", but you may sometimes want to add a delay before taking a screenshot, to wait for animations to end for example. \r\nThere is a flag for this purpose, `--virtual-time-budget=VALUE_IN_MILLISECONDS`. You can use it like so:\r\n\r\n```python\r\nhti = Html2Image(\r\n    custom_flags=['--virtual-time-budget=10000', '--hide-scrollbars']\r\n)\r\n\r\nhti.screenshot(url='http://example.org')\r\n```\r\n\r\n- **Default flags**\r\n\r\nFor ease of use, some flags are set by default. However default flags are not used if you decide to specify `custom_flags` or change the value of `browser.flags`:\r\n\r\n```python\r\n# Taking a look at the default flags\r\n\u003e\u003e\u003e hti = Html2Image()\r\n\u003e\u003e\u003e hti.browser.flags\r\n['--default-background-color=000000', '--hide-scrollbars']\r\n\r\n# Changing the value of browser.flags gets rid of the default flags.\r\n\u003e\u003e\u003e hti.browser.flags = ['--1', '--2']\r\n\u003e\u003e\u003e hti.browser.flags\r\n['--1', '--2'] \r\n\r\n# Using the custom_flags parameter gets rid of the default flags.\r\n\u003e\u003e\u003e hti = Html2Image(custom_flags=['--a', '--b'])\r\n\u003e\u003e\u003e hti.browser.flags\r\n['--a', '--b']\r\n```\r\n\r\n## Using the CLI\r\nHTML2image comes with a Command Line Interface which you can use to generate screenshots from files and URLs on the go. You can call it by typing `hti` or `html2image` into a terminal.\r\n\r\n\r\n**Example Usage (quick start):**  \r\nScreenshot a URL with a specific output name and size:\r\n```bash\r\nhti --url https://example.com --save-as example_page.png --size 1280,720\r\n```\r\n\r\nScreenshot multiple HTML files, applying a common CSS file, and saving with custom names:\r\n```bash\r\nhti --html-file page1.html page2.html --css-file common_styles.css --save-as shot1.jpg shot2.jpg\r\n```\r\n\r\nScreenshot an HTML string with a custom browser flags and verbose output:\r\n```bash\r\nhti --html-string \"\u003ch1\u003eTest\u003c/h1\u003e\u003cp\u003eContent\u003c/p\u003e\" --custom-flags '--no-sandbox' -v\r\n```\r\n\r\n**Html2Image Instance Configuration:**\r\n\r\nThese arguments configure the underlying `Html2Image` instance.\r\n\r\n| Argument | Description | Example |\r\n|----------|-------------|---------|\r\n| `-h, --help` | Show the help message and exit. | `hti --help`  |\r\n| `-o, --output-path PATH` | Directory to save screenshots. (Default: current working directory)| `hti --url example.com -o my_images/`  |\r\n| `--browser BROWSER`| Browser to use. Choices: `chrome`, `chromium`, `google-chrome`, `google-chrome-stable`, `googlechrome`, `edge`, `chrome-cdp`, `chromium-cdp`. (Default: `chrome`)| `hti --url example.com --browser edge` |\r\n| `--browser-executable EXECUTABLE_PATH` | Path to the browser executable. Auto-detected if not provided. | `hti --browser-executable /usr/bin/google-chrome-stable`|\r\n| `--cdp-port PORT`  | CDP port for CDP-enabled browsers (e.g., `chrome-cdp`). (Default: library-dependent)| `hti --browser chrome-cdp --cdp-port 9222 --url example.com`  |\r\n| `--temp-path TEMP_DIR_PATH` | Directory for temporary files. (Default: system temp directory in an `html2image` subfolder)  | `hti --html-file page.html --temp-path /my/tmp`|\r\n| `--keep-temp-files`| Do not delete temporary files after screenshot generation.| `hti --html-file page.html --keep-temp-files`  |\r\n| `--custom-flags [FLAG ...]` | Custom flags to pass to the browser (e.g., `'--no-sandbox' '--disable-gpu'`). If provided, these flags will be used. | `hti --url example.com --custom-flags '--no-sandbox' '--disable-gpu'` \u003cbr\u003e `hti --url example.com --custom-flags '--no-sandbox --disable-gpu'` |\r\n\r\n**Screenshot Sources:**\r\n\r\nSpecify what content to screenshot. At least one source type is required.\r\n\r\n| Argument | Description | Example |\r\n|----------|-------------|---------|\r\n| `-U, --url [URL ...]` | URL(s) to screenshot. | `hti -U https://python.org https://example.com`|\r\n| `--html-file [FILE ...]` | HTML file(s) to screenshot. | `hti --html-file mypage.html another.html`  |\r\n| `--html-string [STRING ...]`| HTML string(s) to screenshot.  | `hti --html-string \"\u003ch1\u003eHello\u003c/h1\u003e\" \"\u003ch2\u003eWorld\u003c/h2\u003e\"` |\r\n| `--css-file [FILE ...]`  | CSS file(s) to load. Used by HTML files or applied with HTML strings. | `hti --html-file page.html --css-file style1.css style2.css`  |\r\n| `--css-string [STRING ...]` | CSS string(s) to apply. Combined and used with HTML strings. | `hti --html-string \"\u003ch1\u003eHi\u003c/h1\u003e\" --css-string \"body{color:red;}\" \"h1{font-size:40px;}\"` |\r\n| `-O, --other-file [FILE ...]`  | Other file(s) to screenshot (e.g., SVG).| `hti -O star.svg`|\r\n\r\n**Screenshot Output Options:**\r\n\r\nControl how the screenshots are saved.\r\n\r\n| Argument | Description | Example |\r\n|----------|-------------|---------|\r\n| `-S, --save-as [FILENAME ...]` | Filename(s) for output images. If not provided or fewer names than items, names are auto-generated (e.g., `screenshot.png`, `screenshot_0.png`). | `hti -U python.org example.com -S py.png ex.png`  |\r\n| `-s, --size [W,H ...]`| Size(s) for screenshots as `Width,Height`. If one W,H pair is given, it applies to all screenshots. If multiple W,H pairs are given, they apply to corresponding screenshots sequentially; if fewer pairs than items, the last pair is repeated. If omitted, the library's default (1920,1080) is used. Width and height must be positive integers. | `hti -U python.org --size 800,600` \u003cbr\u003e `hti -U python.org example.com -s 800,600 1024,768` |\r\n\r\n**General Options:**\r\n\r\n| Argument | Description | Example |\r\n|----------|-------------|---------|\r\n| `-q, --quiet`| Suppress informational output from html2image library (sets `disable_logging=True`). | `hti -U python.org -q` |\r\n| `-v, --verbose` | Enable verbose output, including browser commands if supported by the browser handler.  | `hti -U python.org -v` |  \r\n\r\n\u003cbr\u003e\r\n\r\n### Using a Docker Container\r\n\r\nYou can also test the package and the CLI without having to install everything on your local machine, via a Docker container.\r\n\r\n- First `git clone` this repo\r\n- `cd` inside it\r\n- Build the image : `docker build -t html2image .`\r\n- Run and get inside the container : `docker run -it html2image /bin/bash`\r\n\r\nInside that container, the `html2image` package as well as `chromium` are installed.\r\n\r\nYou can load and execute a python script to use the package, or simply use the CLI.\r\n\r\nOn top of that, you can also use [volumes](https://docs.docker.com/storage/volumes/) to bind a container directory to your local machine directory, allowing you to retrieve the generated images, or even load some resources (HTML, CSS or Python files).\r\n\r\n## FAQ\r\n\r\n- Can I automatically take a full page screenshot?  \r\n**Sadly no**, it is not easily possible. Html2Image relies on the headless mode of Chrome/Chromium browsers to take screenshots and there is no way to \"ask\" for a full page screenshot at the moment. If you know a way (by estimating the page size for example), please open an issue or a discussion!\r\n\r\n- Can I add delay before taking a screenshot?   \r\n**Yes** you can, please take a look at the `Change browser flags` section of the readme.\r\n\r\n- Can I speed up the screenshot-taking process?  \r\n**Yes**, when you are taking a lot of screenshots, you can achieve better performance using Parallel Processing or Multiprocessing methods. You can find an [example of it here](https://github.com/vgalin/html2image/issues/28#issuecomment-862608053).\r\n\r\n- Can I make a cookie modal disappear?  \r\n**Yes and no**. **No**, because there is no options to do it magically and [extensions are not supported in headless Chrome](https://bugs.chromium.org/p/chromium/issues/detail?id=706008#c5) (The [`I don't care about cookies`](https://www.i-dont-care-about-cookies.eu/) extension would have been useful in this case). **Yes**, because you can make any element of a page disappear by retrieving its source code, modifying it as you wish, and finally screenshotting the modified source code.\r\n\r\n\r\n## Contributing and Local Development\r\n\r\nIf you want to contribute to `html2image` or run tests locally, follow these steps:\r\n\r\n1.  **Clone the repository:**\r\n    ```bash\r\n    git clone https://github.com/vgalin/html2image.git\r\n    cd html2image\r\n    ```\r\n\r\n2.  **Install [uv](https://github.com/astral-sh/uv)** by following the installation instructions on the `uv` GitHub page.\r\n\r\n3.  **Create and activate a virtual environment:**\r\n    ```bash\r\n    uv venv\r\n    source .venv/bin/activate  # On Linux/macOS\r\n    # .\\.venv\\Scripts\\Activate.ps1  # On Windows PowerShell\r\n    # .\\.venv\\Scripts\\activate.bat  # On Windows CMD\r\n    ```\r\n\r\n4.  **Install dependencies (including development tools):**\r\n    ```bash\r\n    uv pip install -e \".[dev]\"\r\n    ```\r\n    This installs the package in editable mode along with all dependencies needed for testing and linting.\r\n\r\n### Running Tests\r\nOnly basic testing is available at the moment.\r\nTo run the test suite:\r\n```console\r\npytest\r\n```\r\nOr, using `uv`'s runner:\r\n```console\r\nuv run pytest\r\n```\r\n\r\n\r\n\r\n## TODO List\r\n-   A nice CLI (currently in a WIP state).\r\n-   Support for other browsers, such as Firefox, once their screenshot feature becomes operational.\r\n-   PDF generation?\r\n-   Issue templates, pull request template, code of conduct.\r\n\r\n---\r\n\r\n*If you see any typos or notice things that are oddly said, feel free to create an issue or a pull request.*\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvgalin%2Fhtml2image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvgalin%2Fhtml2image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvgalin%2Fhtml2image/lists"}