Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
exam-scan
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RWTHmoodle
exam-scan
Merge requests
!13
Hotfix
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Hotfix
rohlfing-master-patch-43730
into
master
Overview
0
Commits
1
Pipelines
0
Changes
1
Merged
Christian Rohlfing
requested to merge
rohlfing-master-patch-43730
into
master
4 years ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
to solve merging issues. Sorry.
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
cfa0eeef
1 commit,
4 years ago
1 file
+
10
−
9
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
watermark.py
+
10
−
9
Options
@@ -142,13 +142,15 @@ def watermark_pdf(infolder, tmpdir, outfolder, dpi, pdf_file):
#Watermarking PDF page images
img_folder
=
os
.
listdir
(
tmpdir
)
img_files
=
[
_
for
_
in
img_folder
if
_
[
-
4
:]
==
"
.jpg
"
and
(
_
.
split
(
'
.
'
,
1
)[
0
]).
split
(
'
_
'
,
1
)[
0
]
==
matnum
]
#TODO: call watermark_template as in merge request described
#TODO: temporary single pdf pages should be stored in tmpdir
#Create template
template
=
create_watermark_template
(
dpi
,
tmpdir
,
matnum
,
img_files
[
0
])
for
img_file
in
img_files
:
watermark_img
(
dpi
,
tmpdir
,
outfolder
,
matnum
,
img_file
)
watermark_img
(
dpi
,
tmpdir
,
outfolder
,
template
,
img_file
)
#Combining watermarked PDF pages into one PDF
filenames
=
[
_
for
_
in
os
.
listdir
(
outfolder
)
if
_
[
-
4
:]
==
"
.pdf
"
and
(
_
.
split
(
'
.
'
,
1
)[
0
]).
split
(
'
_
'
,
1
)[
0
]
==
matnum
]
filenames
.
sort
()
if
len
(
filenames
)
>
0
:
combine_all_pdfs
(
outfolder
+
'
/
'
,
filenames
)
@@ -205,12 +207,11 @@ if __name__ == '__main__':
starttime
=
time
.
time
()
#Call watermarking pipeline in parallel
if
cores
>
1
:
watermark_pdf_p
=
Pool
(
cores
)
watermark_pdf_fun
=
partial
(
watermark_pdf
,
infolder
,
tmpdir
,
outfolder
,
dpi
)
watermark_pdf_p
.
map
(
watermark_pdf_fun
,
pdf_files
)
watermark_pdf_p
.
close
()
watermark_pdf_p
.
join
()
watermark_pdf_p
=
Pool
(
cores
)
watermark_pdf_fun
=
partial
(
watermark_pdf
,
infolder
,
tmpdir
,
outfolder
,
dpi
)
watermark_pdf_p
.
map
(
watermark_pdf_fun
,
pdf_files
)
watermark_pdf_p
.
close
()
watermark_pdf_p
.
join
()
endtime
=
time
.
time
()
print
(
'
All PDFs are watermarked and can be found in
'
+
outfolder
+
'
folder
'
)
Loading