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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IENT
exam-scan
Commits
c47a94d2
Commit
c47a94d2
authored
5 years ago
by
Christian Rohlfing
Browse files
Options
Downloads
Patches
Plain Diff
- comments to splitting part in watermark.sh
parent
da8c29e5
No related branches found
No related tags found
No related merge requests found
Pipeline
#286748
passed
5 years ago
Stage: build-docker
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
watermark.sh
+30
-12
30 additions, 12 deletions
watermark.sh
with
30 additions
and
12 deletions
watermark.sh
+
30
−
12
View file @
c47a94d2
...
...
@@ -20,8 +20,8 @@ Options:
-o, --out output folder. Default: ./pdfs_watermarked
-c, --cores number of cores for parallel processing. Default: 1
-d, --dpi dpi parameter for conversion from pdf to images. Default: 250
-
s
, --
sp
lit
flag to split A3 pages to A4 and resorts them
-q, --qua
lit
y
quality parameter for jpeg. Default: 25
"
-
q
, --
qua
lit
y
quality parameter for jpeg. Default: 25
--sp
lit
a3
flag to split A3 landscape pages to A4 portrait pages and resorts them
"
# -allow a command to fail with !’s side effect on errexit
# -use return value from ${PIPESTATUS[0]}, because ! hosed $?
...
...
@@ -31,8 +31,8 @@ if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
exit
1
fi
OPTIONS
=
hiocd
s
qv
LONGOPTS
=
help
,in:,out:,cores:,dpi:,split,quality:,verbose
OPTIONS
=
hiocdqv
LONGOPTS
=
help
,in:,out:,cores:,dpi:,split
a3
,quality:,verbose
# -regarding ! and PIPESTATUS see above
# -temporarily store output to be able to check for errors
...
...
@@ -75,7 +75,7 @@ while true; do
quality
=
"
$2
"
shift
2
;;
-s
|
--split
)
--split
a3
)
split
=
y
shift
1
;;
...
...
@@ -184,31 +184,48 @@ doit () {
exit
fi
# convert pdf into images
# Convert PDF into images
# This may take a while depending on ${dpi}
# (which should not be set to a higher value than the DPI of the scanning device!)
echo
echo
"Convert PDF into images"
pdftoppm
-r
${
dpi
}
-png
$longinpdf
"
${
tmpfolder
}
"
/page
# Split
# Split A3 pages
# scanning exams with the feeder of the copy machine results in double paged A3
# here, we split these A3 pages into two A4 ones and resort them accordingly
# which is the inverse of "brochure print"
if
[[
"
$split
"
=
"y"
]]
;
then
echo
echo
"Split
PDF
A3 pages into
A4
"
echo
"Split
landscape
A3 pages into
each two portrait A4 pages
"
# rename
a
3 pages
# rename
A
3 pages
for
longpage
in
"
${
tmpfolder
}
"
/page
*
.png
;
do
page
=
$(
basename
"
${
longpage
}
"
)
mv
"
$longpage
"
"
${
tmpfolder
}
/tmppage_a3
${
page
}
"
done
pcnt
=
1
for
longa3page
in
"
${
tmpfolder
}
"
/tmppage_a3
*
.png
;
do
echo
"
${
longa3page
}
"
# Split landscape A3 into two portrait A4
# Split landscape A3
page
into two portrait A4
pages
convert
"
${
longa3page
}
"
-crop
50%x100% +repage
"
${
tmpfolder
}
"
/tmppage_a4_%02d.png
# Reorder
# Example: 4 A3 pages, printed on both sides
# yields a brochure with 16 A4 pages
#
# 1st A3 page 2nd A3 page 3rd A3 page ... 8th A3 page
# |-----,-----| |-----,-----| |-----,-----| |-----,-----|
# |--16-,---1-| |---2-,--15-| |--14-,---3-| |---8-,---9-|
# |-----,-----| |-----,-----| |-----,-----| |-----,-----|
#
# results in
# 1st A4 2nd A4 ... 16th A4 page
# |-----| |-----| |-----|
# |---1-| |---2-| |--16-|
# |-----| |-----| |-----|
numdoublepage
=
$(
find
"
${
tmpfolder
}
"
/
-type
f
-name
"tmppage_a3*.png"
|
wc
-l
)
numsinglepage
=
$((
numdoublepage
*
2
))
...
...
@@ -220,7 +237,7 @@ doit () {
numdest2
=
$((
pcnt
))
fi
# Convert to %02d format # TODO: this
must be
simpler!
# Convert to %02d format # TODO: this
should be obtained
simpler!
if
[[
${#
numdest1
}
-lt
2
]]
;
then
numdest1
=
"00
${
numdest1
}
"
numdest1
=
"
${
numdest1
:
-2
}
"
...
...
@@ -242,6 +259,7 @@ doit () {
rm
"
$tmpfolder
"
/tmppage_
*
.png
fi
## split
# Watermarking
echo
echo
"Watermarking"
...
...
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