Skip to content

Commit

Permalink
Merge pull request #846 from sbrunner/fix-autorotate-notext
Browse files Browse the repository at this point in the history
Fix auto rotate when there is not text in the image
  • Loading branch information
sbrunner authored Sep 19, 2022
2 parents 5918c93 + 0279316 commit 0f4cca8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
build:
name: Continuous integration
runs-on: ubuntu-20.04
timeout-minutes: 30
timeout-minutes: 40
if: "!startsWith(github.event.head_commit.message, '[skip ci] ')"

steps:
Expand Down Expand Up @@ -66,9 +66,7 @@ jobs:
retention-days: 5
if: failure()

- run: make build-all
- run: docker login --username=${{ secrets.DOCKER_USERNAME }} --password=${{ secrets.DOCKER_PASSWORD
}}
- run: docker login --username=${{ secrets.DOCKER_USERNAME }} --password=${{ secrets.DOCKER_PASSWORD }}

- name: Init pypi
run: |
Expand Down Expand Up @@ -100,3 +98,10 @@ jobs:
run: |
c2cciutils-publish --group=docker
if: env.HAS_SECRETS == 'HAS_SECRETS'

- run: make build-all

- name: Publish Docker all
run: |
c2cciutils-publish --group=docker-all
if: env.HAS_SECRETS == 'HAS_SECRETS'
21 changes: 9 additions & 12 deletions .github/workflows/rebuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
rebuild:
runs-on: ubuntu-20.04
name: Rebuild
timeout-minutes: 30
timeout-minutes: 40

strategy:
fail-fast: false
Expand Down Expand Up @@ -70,17 +70,14 @@ jobs:
retention-days: 5
if: failure()

- run: docker login --username=${{ secrets.DOCKER_USERNAME }} --password=${{ secrets.DOCKER_PASSWORD }}

- name: Publish
run: c2cciutils-publish --group=docker --type=rebuild --branch=${{ matrix.branch }}

- run: make build-all
- run: docker login --username=${{ secrets.DOCKER_USERNAME }} --password=${{ secrets.DOCKER_PASSWORD
}}

- name: Init pypi
- name: Publish Docker all
run: |
echo "[pypi]" > ~/.pypirc
echo "username = ${{ secrets.PYPI_USERNAME }}" >> ~/.pypirc
echo "password = ${{ secrets.PYPI_PASSWORD }}" >> ~/.pypirc
pip install --user wheel twine
- name: Publish
run: c2cciutils-publish --group=docker --type=rebuild --branch=${{ matrix.branch
}}
c2cciutils-publish --group=docker-all
if: env.HAS_SECRETS == 'HAS_SECRETS'
3 changes: 3 additions & 0 deletions ci/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ publish:
group: docker
tags:
- '{version}'
- name: sbrunner/scan-to-paperless
group: docker-all
tags:
- '{version}-all'
repository:
github:
Expand Down
9 changes: 6 additions & 3 deletions scan_to_paperless/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,9 +725,12 @@ def autorotate(context: Context) -> None:
return
with tempfile.NamedTemporaryFile(suffix=".png") as source:
cv2.imwrite(source.name, context.get_masked())
orientation_lst = output(["tesseract", source.name, "-", "--psm", "0", "-l", "osd"]).splitlines()
orientation_lst = [e for e in orientation_lst if "Orientation in degrees" in e]
context.rotate(int(orientation_lst[0].split()[3]))
try:
orientation_lst = output(["tesseract", source.name, "-", "--psm", "0", "-l", "osd"]).splitlines()
orientation_lst = [e for e in orientation_lst if "Orientation in degrees" in e]
context.rotate(int(orientation_lst[0].split()[3]))
except subprocess.CalledProcessError:
print("Not text found")


def draw_line( # pylint: disable=too-many-arguments
Expand Down

0 comments on commit 0f4cca8

Please sign in to comment.