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
Add CLI, improve image generation, and enhance resolution handling
- Implemented Command Line Interface (CLI) for capturing screenshots
- Added support for pixel and physical (cm) dimensions in image generation
- Introduced UnitConverter for precise unit conversions
- Enhanced resolution handling with DPI and scale factor support
- Added comprehensive test coverage for new features
- Updated project configuration and dependencies
- Improved documentation and usage examples in README
@@ -247,7 +253,7 @@ You can see the list of available releases on the [GitHub Releases](https://gith
247
253
248
254
We follow [Semantic Versions](https://semver.org/) specification.
249
255
250
-
We use [`Release Drafter`](https://github.com/marketplace/actions/release-drafter). As pull requests are merged, a draft release is kept up-to-date listing the changes, ready to publish when you’re ready. With the categories option, you can categorize pull requests in release notes using labels.
256
+
We use [`Release Drafter`](https://github.com/marketplace/actions/release-drafter). As pull requests are merged, a draft release is kept up-to-date listing the changes, ready to publish when you're ready. With the categories option, you can categorize pull requests in release notes using labels.
251
257
252
258
For Pull Request this labels are configured, by default:
253
259
@@ -288,4 +294,104 @@ This project is licensed under the terms of the `MIT` license. See [LICENSE](htt
288
294
This project was generated with [`python-package-template`](https://github.com/TezRomacH/python-package-template).
289
295
290
296
## Alternative
297
+
291
298
1.<https://github.com/vgalin/html2image>
299
+
300
+
## Usage
301
+
302
+
### Basic Usage
303
+
304
+
```python
305
+
from snap_html import generate_image_sync
306
+
from pathlib import Path
307
+
308
+
# Capture from URL
309
+
screenshot = generate_image_sync(
310
+
"https://www.example.com",
311
+
resolution={"width": 1920, "height": 1080},
312
+
output_file=Path("screenshot.png")
313
+
)
314
+
315
+
# Capture with physical dimensions (in centimeters)
316
+
screenshot = generate_image_sync(
317
+
"https://www.example.com",
318
+
resolution={
319
+
"cm_width": 21, # A4 width
320
+
"cm_height": 29.7, # A4 height
321
+
"dpi": 300# Print quality DPI
322
+
},
323
+
output_file=Path("high_quality.png")
324
+
)
325
+
```
326
+
327
+
### Resolution Options
328
+
329
+
The library supports two ways to specify output resolution:
330
+
331
+
1. Pixel Dimensions:
332
+
333
+
```python
334
+
resolution = {
335
+
"width": 1920, # Width in pixels
336
+
"height": 1080# Height in pixels
337
+
}
338
+
```
339
+
340
+
2. Physical Dimensions:
341
+
342
+
```python
343
+
resolution = {
344
+
"cm_width": 21, # Width in centimeters
345
+
"cm_height": 29.7, # Height in centimeters
346
+
"dpi": 300# Dots per inch (optional, defaults to 300)
347
+
}
348
+
```
349
+
350
+
### Batch Processing
351
+
352
+
For better performance when capturing multiple screenshots:
0 commit comments