Browse Source

Added instructions for the two-sided option.

dev
Franco Masotti 4 years ago
parent
commit
f5acd6efdb
  1. 12
      fbopt
  2. 65
      spectrscan

12
fbopt

@ -46,8 +46,9 @@ Options:
-t, --two-sided toggle preserve the order in
double sided paper: scan a batch of
papers one side, then the other
--two-sided-reverse same as '--odd-even' but with the need of
reversing every single paper.
--two-sided-reverse same as '--two-sided' but with the need of
reversing every single paper. This
option conflicts with '--two-sided'
-u, --unpaper[=OPTIONS] enable unpaper. You may pass
options to unpaper
@ -182,6 +183,10 @@ main()
# From now on you should call a function or an external program
# using the values of the flag variables.
[ "${two_sided}" = 'true' ] \
&& [ "${two_sided_reverse}" = 'true' ] \
&& getopt_error \
&& return 1
[ "${list_modes}" = 'true' ] \
&& get_supported_modes "$(get_supported_parameters)" \
&& return ${?}
@ -191,6 +196,8 @@ main()
[ "${list_sources}" = 'true' ] \
&& get_supported_sources "$(get_supported_parameters)" \
&& return ${?}
# Override two_sided value if necessary.
[ "${two_sided_reverse}" = 'true' ] && two_sided='reverse'
local output_file="${1}"
[ -z "${output_file}" ] && getopt_error && return 1
@ -201,6 +208,7 @@ main()
"${resolution}" \
"${source}" \
"${unpaper}" \
"${two_sided}" \
"${output_file}"
}

65
spectrscan

@ -40,20 +40,29 @@ check_software()
pamfix
} 1>/dev/null 2>/dev/null
scan()
get_last_page_side_a()
{
local file_counter="${1}"
local batch_start=1
local batch_increment=1
ls spectrscan_out*.pnm | sort --reverse | head -n1 | tr -d [a-z]._
}
if [ "$file_counter" = "odd" ]; then
batch_start=1
batch_increment=2
elif [ "$file_counter" = "even" ]; then
scan()
{
if [ "${two_sided}" = 'true' ] && [ "${side_b}" = 'true' ]; then
# side_b
batch_start=$(("$(get_last_page_side_a)"+1))
batch_increment=-2
elif [ "${two_sided}" = 'reverse' ] && [ "${side_b}" = 'true' ]; then
# side_b
batch_start=2
batch_increment=2
else
fi
if [ "${two_sided}" != 'false' ] && [ "${side_a}" = 'true' ]; then
# true, reverse, first side.
batch_start=1
batch_increment=2
fi
if [ "${two_sided}" = 'false' ]; then
# single sided
batch_start=1
batch_increment=1
fi
@ -211,20 +220,31 @@ chain()
mkdir "$TMP_DIR"
pushd "$TMP_DIR"
if [ "$odd_even" = 'true' ]; then
scan "odd" \
if [ "${two_sided}" = 'true' ]; then
side_a='true'
scan \
&& printf "%s\n" 'turn the paper(s) and hit return when ready' \
&& read \
&& scan "even"
&& side_a='false' \
&& side_b='true' \
&& scan
elif [ "${two_sided}" = 'reverse' ]; then
side_a='true'
scan \
&& printf "%s\n" 'turn the paper(s) and hit return when ready' \
&& read \
&& side_a='false' \
&& side_b='true' \
&& scan
else
scan
fi
# Feeder out of documents.
if [ ${?} -eq 7 ]; then
cleanup
return 1
fi
# Feeder out of documents unexpectedly.
# if [ ${?} -eq 7 ]; then
# cleanup
# return 1
# fi
pnm_to_pdf
pdf_cat
@ -241,15 +261,16 @@ preliminary_checks()
resolution="${3}"
source="${4}"
unpaper_options="${5}"
output_file="${6}"
two_sided="${6}"
output_file="${7}"
# Get the parameters and check that the scanner is connected.
supported_params="$(get_supported_parameters)"
[ ${?} -ne 0 ] && return ${?}
{ check_supported_parameters "modes" "${mode}" \
&& check_supported_parameters "resolutions" "${resolution}" \
&& check_supported_parameters "sources" "${source}"; } \
{ check_supported_parameters 'modes' "${mode}" \
&& check_supported_parameters 'resolutions' "${resolution}" \
&& check_supported_parameters 'sources' "${source}"; } \
|| return 1
chain