diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index 7df3803..0000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,20 +0,0 @@ -## Description - -Please include a summary of the change and which issue is fixed. -Please also include relevant motivation and context. -List any dependencies that are required for this change. - -- Related issues: - - #123 - -## Changes in this PR - -- Added something -- Fixed something -- Refactored something -- ... - -## How has this been tested? - -Please explain how the changes are tested. -Does this change include unit-tests? Did you test it manually? etc. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index b732b6e..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,176 +0,0 @@ -name: CI - -on: - push: - branches: - - master - pull_request: - -jobs: - black: - runs-on: ubuntu-latest - strategy: - matrix: - python: ['3.8'] - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install dependencies - run: bash depends/install_ubuntu_depends.sh - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - - name: Upgrade pip, setuptools and wheel - run: python -m pip install --upgrade pip setuptools wheel - - name: Install synthtiger - run: pip install . - - name: Install black - run: pip install --upgrade black==22.3.0 - - name: Run black - run: black --check . - - isort: - runs-on: ubuntu-latest - strategy: - matrix: - python: ['3.8'] - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install dependencies - run: bash depends/install_ubuntu_depends.sh - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - - name: Upgrade pip, setuptools and wheel - run: python -m pip install --upgrade pip setuptools wheel - - name: Install synthtiger - run: pip install . - - name: Install isort - run: pip install --upgrade isort==5.10.1 - - name: Run isort - run: isort --profile black --check . - - mypy: - runs-on: ubuntu-latest - strategy: - matrix: - python: ['3.8'] - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install dependencies - run: bash depends/install_ubuntu_depends.sh - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - - name: Upgrade pip, setuptools and wheel - run: python -m pip install --upgrade pip setuptools wheel - - name: Install synthtiger - run: pip install . - - name: Install mypy - run: pip install --upgrade mypy - - name: Run mypy - run: mypy --ignore-missing-imports --install-types --non-interactive synthtiger - - pylint: - runs-on: ubuntu-latest - strategy: - matrix: - python: ['3.8'] - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install dependencies - run: bash depends/install_ubuntu_depends.sh - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - - name: Upgrade pip, setuptools and wheel - run: python -m pip install --upgrade pip setuptools wheel - - name: Install synthtiger - run: pip install . - - name: Install pylint - run: pip install --upgrade pylint - - name: Run pylint - run: pylint --errors-only -s y synthtiger - - pytest-ubuntu: - runs-on: ubuntu-latest - strategy: - matrix: - python: ['3.6', '3.7', '3.8', '3.9', '3.10'] - fail-fast: false - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install dependencies - run: bash depends/install_ubuntu_depends.sh - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - - name: Upgrade pip, setuptools and wheel - run: python -m pip install --upgrade pip setuptools wheel - - name: Install synthtiger - run: pip install . - - name: Install pytest - run: pip install --upgrade pytest - - name: Run pytest - run: pytest . - - pytest-macos: - runs-on: macos-latest - strategy: - matrix: - python: ['3.6', '3.7', '3.8', '3.9', '3.10'] - fail-fast: false - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install dependencies - run: bash depends/install_macos_depends.sh - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - - name: Upgrade pip, setuptools and wheel - run: python -m pip install --upgrade pip setuptools wheel - - name: Install synthtiger - run: pip install . - - name: Install pytest - run: pip install --upgrade pytest - - name: Run pytest - run: pytest . - - pytest-windows: - runs-on: windows-latest - strategy: - matrix: - python: ['3.6', '3.7', '3.8', '3.9', '3.10'] - fail-fast: false - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Set up MSYS2 - uses: msys2/setup-msys2@v2 - - name: Add MSYS2 MinGW path - run: echo "D:\a\_temp\msys64\mingw64\bin" >> $env:GITHUB_PATH - - name: Install dependencies - run: msys2 depends/install_windows_depends.sh - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - - name: Upgrade pip, setuptools and wheel - run: python -m pip install --upgrade pip setuptools wheel - - name: Install synthtiger - run: pip install . - - name: Install pytest - run: pip install --upgrade pytest - - name: Run pytest - run: pytest . diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 9ab7993..0000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Docs - -on: - push: - branches: [master] - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install dependencies - run: bash depends/install_ubuntu_depends.sh - - name: Set up python - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Upgrade pip, setuptools and wheel - run: python -m pip install --upgrade pip setuptools wheel - - name: Install synthtiger - run: pip install . - - name: Install sphinx - run: pip install --upgrade sphinx furo - - name: Build docs - run: make -C docs clean html - - name: Deploy docs - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: docs/_build/html diff --git a/setup.py b/setup.py index 5077a6b..41b6d59 100644 --- a/setup.py +++ b/setup.py @@ -37,9 +37,9 @@ def read_long_description(): "blend-modes", "fonttools", "imgaug", - "numpy", + "numpy==1.26", "opencv-python", - "pillow>=8.2.0", + "pillow>=11.0.0", "pygame", "python-bidi", "pytweening", diff --git a/synthtiger/layers/text_layer.py b/synthtiger/layers/text_layer.py index e45d0af..d637afa 100644 --- a/synthtiger/layers/text_layer.py +++ b/synthtiger/layers/text_layer.py @@ -172,11 +172,13 @@ def _get_bbox(self, text, font, vertical): if not vertical: ascent, descent = font.getmetrics() - width = font.getsize(text, direction=direction)[0] + left, top, right, bottom = font.getbbox(text, direction=direction) + width = right - left height = ascent + descent bbox = [0, -ascent, width, height] else: - width, height = font.getsize(text, direction=direction) + left, top, right, bottom = font.getbbox(text, direction=direction) + width, height = right - left, bottom-top bbox = [-width // 2, 0, width, height] return bbox diff --git a/synthtiger/utils/image_util.py b/synthtiger/utils/image_util.py index 6369431..1f4b070 100644 --- a/synthtiger/utils/image_util.py +++ b/synthtiger/utils/image_util.py @@ -230,7 +230,12 @@ def to_bbox(quad): def merge_quad(quads): quads = np.array(quads, dtype=np.float32) - topleft = np.amin(quads, axis=(0, 1)) + try: + topleft = np.amin(quads, axis=(0, 1)) + except Exception as e: + print(e) + print(quads) + raise Exception() bottomright = np.amax(quads, axis=(0, 1)) width, height = bottomright - topleft quad = np.array(