You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HTML2Image is a lightweight Python package that acts as a wrapper around the headless mode of existing web browsers to generate images from URLs and from HTML+CSS strings or files.
**A lightweight Python package acting a wrapper around the headless mode of existing web browsers, allowing images generation from HTML/CSS strings, files and URLs.**
24
+
25
+
</div>
26
+
15
27
16
28
This package has been tested on Windows, Ubuntu (desktop and server) and MacOS. It is currently in a work in progress stage. If you encounter any problem or difficulties while using it, feel free to open an issue on the GitHub page of this project. Feedback is also welcome!
17
29
18
30
19
31
## Principle
20
32
33
+
21
34
Most 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 testings 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.
22
35
23
36
However, 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 to create an image from as little as a string.
In addition to this package, at least one of the following browsers **must** be installed on your machine :
37
50
- Google Chrome (Windows, MacOS)
38
51
- Chromium Browser (Linux)
52
+
- Microsoft Edge
39
53
40
54
## Usage
41
55
@@ -45,14 +59,14 @@ from html2image import Html2Image
45
59
hti = Html2Image()
46
60
```
47
61
48
-
<details>
49
-
<summary> Multiple arguments can be passed to the constructor (click to expand):</summary>
62
+
Multiple arguments can be passed to the constructor:
50
63
51
-
-`browser` : Browser that will be used, set by default to `'chrome'` (the only browser supported by HTML2Image at the moment)
64
+
-`browser` : Browser that will be used, can be set to `'chrome'` (default) or `'edge'`.
52
65
-`browser_executable` : The path or the command that can be used to find the executable of a specific browser.
53
66
-`output_path` : Path to the folder to which taken screenshots will be outputed. Default is the current working directory of your python program.
54
67
-`size` : 2-Tuple representing the size of the screenshots that will be taken. Default value is `(1920, 1080)`.
55
68
-`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.
69
+
-`keep_temp_files` : Pass True to this argument to not automatically remove temporary files created in `temp_path`. Default is False.
56
70
57
71
Example:
58
72
```python
@@ -63,8 +77,6 @@ You can also change these values later:
0 commit comments