🚧 Prepare supporting ocrd-sbb-binarize

ocrd-sbb-binarize seems to work but its input does not work with
ocrd-sbb-textline-detector:

https://github.com/qurator-spk/sbb_binarization/issues/8
https://github.com/qurator-spk/sbb_textline_detection/issues/47
This commit is contained in:
Gerber, Mike 2020-10-22 21:08:13 +02:00
parent 053fc0bc34
commit 0841af5491
6 changed files with 57 additions and 6 deletions

View file

@ -62,13 +62,37 @@ annex_get() {
)
}
# Options:
# --no-unpack Do NOT unpack the file
# --strip-components NUMBER (as tar's option)
download_to() {
unpack=1
if [[ "$1" = '--no-unpack' ]]; then
unpack=0
shift
tar_options=""
_options=$(getopt --long no-unpack,strip-components: -- "" "$@")
if [[ $? != 0 ]]; then
echo "Bad parameters for download_to" >&2
exit 1
fi
file_pattern="$1"
eval set -- "$_options"
while true; do
case "$1" in
--no-unpack)
unpack=0
;;
--strip-components)
shift
components=$1
tar_options="$tar_options --strip-components $components"
;;
--)
shift
break
;;
esac
shift
done
download_source="$1"
dest="$2"
@ -79,7 +103,7 @@ download_to() {
if [[ $unpack = 1 ]]; then
mkdir -p "$dest"
# Unpacking relies on tar -a unpacking any tar compression
tar -C "$dest" -af $tmpf -xv
tar -C "$dest" $tar_options -af $tmpf -xv
rm -f $tmpf
else
dest_dir=`dirname "$dest"`