Skip to content

Commit

Permalink
Add rule to assisted split images
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Sep 5, 2022
1 parent cb422c6 commit 5eb360b
Show file tree
Hide file tree
Showing 10 changed files with 594 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN --mount=type=cache,target=/var/lib/apt/lists \

RUN --mount=type=cache,target=/var/lib/apt/lists \
--mount=type=cache,target=/var/cache,sharing=locked \
apt-get install --assume-yes --no-install-recommends python3-pip gnupg
apt-get install --assume-yes --no-install-recommends python3-pip gnupg fonts-dejavu-core

FROM base-all as poetry

Expand Down
17 changes: 17 additions & 0 deletions config.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,20 @@
- **`threshold`** _(integer)_: The threshold used in the Hough transform. Default: `100`.
- **`min_line_length`** _(integer)_: The minimum line length in percentage of the image size used in the Hough transform. Default: `50`.
- **`max_line_gap`** _(integer)_: The maximum line gap in percentage of the image size used in the Hough transform. Default: `100`.
- **`rule`** _(object)_: Configuration of rule displayed in assisted split images.
- **`enable`** _(boolean)_: Default: `True`.
- **`minor_graduation_space`** _(integer)_: Default: `10`.
- **`major_graduation_space`** _(integer)_: Default: `100`.
- **`lines_space`** _(integer)_: Default: `100`.
- **`minor_graduation_size`** _(integer)_: Default: `10`.
- **`major_graduation_size`** _(integer)_: Default: `30`.
- **`graduation_color`** _(array)_: Default: `[0, 0, 0]`.
- **Items** _(integer)_
- **`lines_color`** _(array)_: Default: `[0, 0, 0]`.
- **Items** _(integer)_
- **`lines_opacity`** _(number)_: Default: `0.2`.
- **`graduation_text_font_filename`** _(string)_: Default: `/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf`.
- **`graduation_text_font_size`** _(number)_: Default: `17`.
- **`graduation_text_font_color`** _(array)_: Default: `[0, 0, 0]`.
- **Items** _(integer)_
- **`graduation_text_margin`** _(integer)_: Default: `6`.
17 changes: 17 additions & 0 deletions process.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,20 @@
- **`threshold`** _(integer)_: The threshold used in the Hough transform. Default: `100`.
- **`min_line_length`** _(integer)_: The minimum line length in percentage of the image size used in the Hough transform. Default: `50`.
- **`max_line_gap`** _(integer)_: The maximum line gap in percentage of the image size used in the Hough transform. Default: `100`.
- **`rule`** _(object)_: Configuration of rule displayed in assisted split images.
- **`enable`** _(boolean)_: Default: `True`.
- **`minor_graduation_space`** _(integer)_: Default: `10`.
- **`major_graduation_space`** _(integer)_: Default: `100`.
- **`lines_space`** _(integer)_: Default: `100`.
- **`minor_graduation_size`** _(integer)_: Default: `10`.
- **`major_graduation_size`** _(integer)_: Default: `30`.
- **`graduation_color`** _(array)_: Default: `[0, 0, 0]`.
- **Items** _(integer)_
- **`lines_color`** _(array)_: Default: `[0, 0, 0]`.
- **Items** _(integer)_
- **`lines_opacity`** _(number)_: Default: `0.2`.
- **`graduation_text_font_filename`** _(string)_: Default: `/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf`.
- **`graduation_text_font_size`** _(number)_: Default: `17`.
- **`graduation_text_font_color`** _(array)_: Default: `[0, 0, 0]`.
- **Items** _(integer)_
- **`graduation_text_margin`** _(integer)_: Default: `6`.
127 changes: 127 additions & 0 deletions scan_to_paperless/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@
# WARNING: The required are not correctly taken in account,
# See: https:/camptocamp/jsonschema-gentypes/issues/6
"line_detection": "LineDetection",
# WARNING: The required are not correctly taken in account,
# See: https:/camptocamp/jsonschema-gentypes/issues/6
"rule": "Rule",
},
total=False,
)
Expand Down Expand Up @@ -747,6 +750,58 @@
ROTATE_EVEN_DEFAULT = False


# Default value of the field path 'Rule enable'
RULE_ENABLE_DEFAULT = True


# Default value of the field path 'Rule graduation_color'
RULE_GRADUATION_COLOR_DEFAULT = [0, 0, 0]


# Default value of the field path 'Rule graduation_text_font_color'
RULE_GRADUATION_TEXT_FONT_COLOR_DEFAULT = [0, 0, 0]


# Default value of the field path 'Rule graduation_text_font_filename'
RULE_GRADUATION_TEXT_FONT_FILENAME_DEFAULT = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"


# Default value of the field path 'Rule graduation_text_font_size'
RULE_GRADUATION_TEXT_FONT_SIZE_DEFAULT = 17


# Default value of the field path 'Rule graduation_text_margin'
RULE_GRADUATION_TEXT_MARGIN_DEFAULT = 6


# Default value of the field path 'Rule lines_color'
RULE_LINES_COLOR_DEFAULT = [0, 0, 0]


# Default value of the field path 'Rule lines_opacity'
RULE_LINES_OPACITY_DEFAULT = 0.2


# Default value of the field path 'Rule lines_space'
RULE_LINES_SPACE_DEFAULT = 100


# Default value of the field path 'Rule major_graduation_size'
RULE_MAJOR_GRADUATION_SIZE_DEFAULT = 30


# Default value of the field path 'Rule major_graduation_space'
RULE_MAJOR_GRADUATION_SPACE_DEFAULT = 100


# Default value of the field path 'Rule minor_graduation_size'
RULE_MINOR_GRADUATION_SIZE_DEFAULT = 10


# Default value of the field path 'Rule minor_graduation_space'
RULE_MINOR_GRADUATION_SPACE_DEFAULT = 10


# Default value of the field path 'Arguments run_exiftool'
RUN_EXIFTOOL_DEFAULT = False

Expand All @@ -763,6 +818,78 @@
RUN_PS2PDF_DEFAULT = False


# Rule
#
# Configuration of rule displayed in assisted split images
Rule = TypedDict(
"Rule",
{
# Rule enable
#
# default: True
"enable": bool,
# Rule minor graduation space
#
# default: 10
"minor_graduation_space": int,
# Rule major graduation space
#
# default: 100
"major_graduation_space": int,
# Rule lines space
#
# default: 100
"lines_space": int,
# Rule minor graduation size
#
# default: 10
"minor_graduation_size": int,
# Rule major graduation size
#
# default: 30
"major_graduation_size": int,
# Rule graduation color
#
# default:
# - 0
# - 0
# - 0
"graduation_color": List[int],
# Rule lines color
#
# default:
# - 0
# - 0
# - 0
"lines_color": List[int],
# Rule lines opacity
#
# default: 0.2
"lines_opacity": Union[int, float],
# Rule graduation text font filename
#
# default: /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf
"graduation_text_font_filename": str,
# Rule graduation text font size
#
# default: 17
"graduation_text_font_size": Union[int, float],
# Rule graduation text font color
#
# default:
# - 0
# - 0
# - 0
"graduation_text_font_color": List[int],
# Rule graduation text margin
#
# default: 6
"graduation_text_margin": int,
},
total=False,
)


# Default value of the field path 'Configuration scanimage_arguments'
SCANIMAGE_ARGUMENTS_DEFAULT = ["--format=png", "--mode=color", "--resolution=300"]

Expand Down
81 changes: 81 additions & 0 deletions scan_to_paperless/config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,87 @@
"title": "Line detection max line gap"
}
}
},
"rule": {
"type": "object",
"title": "Rule",
"description": "Configuration of rule displayed in assisted split images",
"properties": {
"enable": {
"title": "Rule enable",
"type": "boolean",
"default": true
},
"minor_graduation_space": {
"title": "Rule minor graduation space",
"type": "integer",
"default": 10
},
"major_graduation_space": {
"title": "Rule major graduation space",
"type": "integer",
"default": 100
},
"lines_space": {
"title": "Rule lines space",
"type": "integer",
"default": 100
},
"minor_graduation_size": {
"title": "Rule minor graduation size",
"type": "integer",
"default": 10
},
"major_graduation_size": {
"title": "Rule major graduation size",
"type": "integer",
"default": 30
},
"graduation_color": {
"title": "Rule graduation color",
"type": "array",
"default": [0, 0, 0],
"items": {
"type": "integer"
}
},
"lines_color": {
"title": "Rule lines color",
"type": "array",
"default": [0, 0, 0],
"items": {
"type": "integer"
}
},
"lines_opacity": {
"title": "Rule lines opacity",
"type": "number",
"default": 0.2
},
"graduation_text_font_filename": {
"title": "Rule graduation text font filename",
"type": "string",
"default": "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
},
"graduation_text_font_size": {
"title": "Rule graduation text font size",
"type": "number",
"default": 17
},
"graduation_text_font_color": {
"title": "Rule graduation text font color",
"type": "array",
"default": [0, 0, 0],
"items": {
"type": "integer"
}
},
"graduation_text_margin": {
"title": "Rule graduation text margin",
"type": "integer",
"default": 6
}
}
}
}
}
Expand Down
Loading

0 comments on commit 5eb360b

Please sign in to comment.