Skip to content

Commit

Permalink
Add crop status image
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jul 18, 2021
1 parent c8bc8ef commit 77ee44f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
- Fix for scan @600 DPI
- Introduce scan mode: `--double-sided` => `--mode=double`, `--no-adf` => `--mode=multi`, new mode `--mode=one`
- Respect the deleted image during the preview
- Add crop status image
18 changes: 14 additions & 4 deletions scan_to_paperless/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,21 @@ def crop(context: Context, margin_horizontal: int, margin_vertical: int) -> None
"""
Margin in px
"""
contours = find_contours(
context.get_masked(),
context.get_px_value("min_box_size_crop", 3),
)
image = context.get_masked()
contours = find_contours(image, context.get_px_value("min_box_size_crop", 3))

if contours:
for contour in contours:
draw_rectangle(image, False, contour)
if context.root_folder is not None and context.image_name is not None:
save_image(
image,
context.root_folder,
"{}-crop".format(context.get_process_count()),
context.image_name,
True,
)

x, y, width, height = get_contour_to_crop(contours, margin_horizontal, margin_vertical)
context.crop(x, y, width, height)

Expand Down

0 comments on commit 77ee44f

Please sign in to comment.