Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
zesje
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Réouven ASSOULY
zesje
Commits
3e65f172
Commit
3e65f172
authored
6 years ago
by
Anton Akhmerov
Committed by
Thomas Roos
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
allow using monochromatic scans
parent
1edeeb49
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
zesje/helpers/pdf_helper.py
+8
-2
8 additions, 2 deletions
zesje/helpers/pdf_helper.py
with
8 additions
and
2 deletions
zesje/helpers/pdf_helper.py
+
8
−
2
View file @
3e65f172
...
...
@@ -258,10 +258,12 @@ def guess_dpi(image_array):
def
rotate_and_shift
(
image_data
,
extracted_qr
,
qr_coords
):
"""
Roll the image such that QR occupies coords specified by the template.
"""
page
,
position
=
extracted_qr
.
page
,
extracted_qr
.
coords
image
=
np
.
as
array
(
image_data
)
image
=
np
.
array
(
image_data
)
if
image
.
shape
[
0
]
<
image
.
shape
[
1
]:
image
=
np
.
transpose
(
image
,
(
1
,
0
,
2
))
image
=
np
.
copy
(
np
.
transpose
(
image
,
((
1
,
0
)
if
len
(
image
.
shape
)
==
2
else
(
1
,
0
,
2
))
))
dpi
=
guess_dpi
(
image
)
h
,
w
,
*
_
=
image
.
shape
...
...
@@ -280,6 +282,10 @@ def rotate_and_shift(image_data, extracted_qr, qr_coords):
shifted_image
=
np
.
roll
(
image
,
shift
[
0
],
axis
=
0
)
shifted_image
=
np
.
roll
(
shifted_image
,
shift
[
1
],
axis
=
1
)
# Workaround of https://github.com/python-pillow/Pillow/issues/3109
if
shifted_image
.
dtype
==
bool
:
shifted_image
=
shifted_image
*
np
.
uint8
(
255
)
return
Image
.
fromarray
(
shifted_image
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment