Skip to content

Conversation

@uho-33
Copy link

@uho-33 uho-33 commented Sep 18, 2025

Summary

This PR adds two new features to improve page break control:

  • --blank-ratio: Makes blank line detection configurable, allowing for noisy images
  • --no-split-content: Prevents content blocks from being split across pages

Details

Blank Line Detection (--blank-ratio)

  • Default (0.0): Strict behavior - all pixels must be > 250 brightness
  • With value > 0: Allow specified ratio of non-blank pixels (e.g., 0.1 = 10% tolerance)
  • Particularly useful for images with compression artifacts or subtle backgrounds

Content Splitting Control (--no-split-content)

  • Default: Content may be split at page boundaries if no gap is found
  • With flag: Forces splits to occur only at content gaps, never cutting through content
  • Includes helpful error handling when content blocks are too tall for selected page size

Usage Examples

# Allow 15% non-blank pixels in "blank" lines
scrollshot2pdf image.png --blank-ratio 0.15

# Prevent content from being split across pages
scrollshot2pdf document.png --no-split-content --page-size legal

Use `--no-split-content` to enable this mode. When enabled content blocks are never split, even creating slices with more blank space if necessary. But if context exceeds page height, it will exit with some suggestions.
Add --blank-ratio argument to control strictness of blank line detection. Default value 0.0 maintains original strict behavior (all pixels > 250). Higher values allow percentage of non-blank pixels in 'blank' lines
@osteele osteele requested a review from Copilot September 22, 2025 13:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces two key features to enhance page break control in scrollshot2pdf: configurable blank line detection and content splitting prevention.

  • Adds --blank-ratio parameter to allow tolerance for noisy pixels in blank line detection
  • Adds --no-split-content flag to prevent splitting content blocks across pages
  • Includes comprehensive error handling and documentation for the new features

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
scrollshot2pdf.py Implements the core functionality for both new features with parameter validation and error handling
README.md Documents the new options with usage examples and detailed explanations
CHANGELOG.md Records the feature additions for version 0.1.2

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

- simplify the gap detection logic
- fix error in the `blank_ratio` argument description
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant