imgbytesizer 0.2.4__tar.gz → 0.2.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- imgbytesizer-0.2.6/.flake8 +3 -0
- imgbytesizer-0.2.6/.github/workflows/ci.yml +45 -0
- imgbytesizer-0.2.6/.github/workflows/publish.yml +179 -0
- imgbytesizer-0.2.6/.gitignore +174 -0
- imgbytesizer-0.2.6/.style.yapf +12 -0
- imgbytesizer-0.2.6/.vscode/extensions.json +10 -0
- imgbytesizer-0.2.6/.vscode/settings.json +15 -0
- imgbytesizer-0.2.6/.vulture_ignore.py +12 -0
- imgbytesizer-0.2.6/CHANGELOG.md +181 -0
- {imgbytesizer-0.2.4 → imgbytesizer-0.2.6}/PKG-INFO +11 -18
- {imgbytesizer-0.2.4 → imgbytesizer-0.2.6}/README.md +1 -0
- imgbytesizer-0.2.6/cliff.toml +99 -0
- imgbytesizer-0.2.6/pyproject.toml +47 -0
- imgbytesizer-0.2.6/pytest.ini +9 -0
- imgbytesizer-0.2.6/scripts/check_version.py +20 -0
- imgbytesizer-0.2.6/scripts/release.sh +46 -0
- imgbytesizer-0.2.6/src/imgbytesizer/__init__.py +11 -0
- {imgbytesizer-0.2.4 → imgbytesizer-0.2.6}/src/imgbytesizer/logger.py +1 -1
- {imgbytesizer-0.2.4 → imgbytesizer-0.2.6}/src/imgbytesizer/resizer.py +251 -210
- imgbytesizer-0.2.6/tests/test_formatter.py +12 -0
- imgbytesizer-0.2.6/tests/test_logger.py +48 -0
- imgbytesizer-0.2.6/tests/test_main.py +128 -0
- imgbytesizer-0.2.6/tests/test_resizer.py +410 -0
- imgbytesizer-0.2.6/tests/test_utils.py +99 -0
- imgbytesizer-0.2.6/tox.ini +44 -0
- imgbytesizer-0.2.6/uv.lock +778 -0
- imgbytesizer-0.2.4/pyproject.toml +0 -40
- imgbytesizer-0.2.4/src/imgbytesizer/__init__.py +0 -7
- {imgbytesizer-0.2.4 → imgbytesizer-0.2.6}/LICENSE +0 -0
- {imgbytesizer-0.2.4 → imgbytesizer-0.2.6}/src/imgbytesizer/formatter.py +0 -0
- {imgbytesizer-0.2.4 → imgbytesizer-0.2.6}/src/imgbytesizer/main.py +0 -0
- {imgbytesizer-0.2.4 → imgbytesizer-0.2.6}/src/imgbytesizer/py.typed +0 -0
- {imgbytesizer-0.2.4 → imgbytesizer-0.2.6}/src/imgbytesizer/utils.py +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: 🧪 CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- main
|
|
10
|
+
|
|
11
|
+
concurrency:
|
|
12
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
13
|
+
cancel-in-progress: true
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
ci:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
23
|
+
name: ⬇️ Checkout repository
|
|
24
|
+
|
|
25
|
+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
|
26
|
+
name: 📦 Setup Python
|
|
27
|
+
with:
|
|
28
|
+
python-version: "3.10"
|
|
29
|
+
|
|
30
|
+
- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
|
|
31
|
+
name: 📦 Setup uv
|
|
32
|
+
|
|
33
|
+
- name: 🔍 Install dependencies
|
|
34
|
+
run: uv sync
|
|
35
|
+
|
|
36
|
+
- name: 🧪 Run tests
|
|
37
|
+
run: uv run tox
|
|
38
|
+
|
|
39
|
+
- name: 📊 Upload coverage
|
|
40
|
+
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
|
|
41
|
+
with:
|
|
42
|
+
files: ./coverage.xml
|
|
43
|
+
fail_ci_if_error: true
|
|
44
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
45
|
+
verbose: true
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
name: 🚀 Publish Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
inputs:
|
|
10
|
+
version_tag:
|
|
11
|
+
description: "Tag to use for the release (e.g., v0.1.0)"
|
|
12
|
+
required: true
|
|
13
|
+
|
|
14
|
+
concurrency:
|
|
15
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
16
|
+
cancel-in-progress: true
|
|
17
|
+
|
|
18
|
+
permissions:
|
|
19
|
+
contents: read
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
check-version:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
26
|
+
name: ⬇️ Checkout repository
|
|
27
|
+
|
|
28
|
+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
|
29
|
+
name: 📦 Setup Python
|
|
30
|
+
with:
|
|
31
|
+
python-version: "3.10"
|
|
32
|
+
|
|
33
|
+
- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
|
|
34
|
+
name: 📦 Setup uv
|
|
35
|
+
|
|
36
|
+
- name: 🔍 Install dependencies
|
|
37
|
+
run: uv sync
|
|
38
|
+
|
|
39
|
+
- name: 🔍 Check version is not already published on PyPI
|
|
40
|
+
run: uv run python scripts/check_version.py
|
|
41
|
+
|
|
42
|
+
release-build:
|
|
43
|
+
runs-on: ubuntu-latest
|
|
44
|
+
needs:
|
|
45
|
+
- check-version
|
|
46
|
+
steps:
|
|
47
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
48
|
+
name: ⬇️ Checkout repository
|
|
49
|
+
|
|
50
|
+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
|
51
|
+
name: 📦 Setup Python
|
|
52
|
+
with:
|
|
53
|
+
python-version: "3.10"
|
|
54
|
+
|
|
55
|
+
- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
|
|
56
|
+
name: 📦 Setup uv
|
|
57
|
+
|
|
58
|
+
- name: 🔍 Install dependencies
|
|
59
|
+
run: uv sync
|
|
60
|
+
|
|
61
|
+
- name: 🏗 Build release
|
|
62
|
+
run: uv run tox -e build
|
|
63
|
+
|
|
64
|
+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
65
|
+
name: 📤 Upload artifact
|
|
66
|
+
with:
|
|
67
|
+
name: release
|
|
68
|
+
path: dist/
|
|
69
|
+
|
|
70
|
+
pypi-publish:
|
|
71
|
+
runs-on: ubuntu-latest
|
|
72
|
+
needs:
|
|
73
|
+
- release-build
|
|
74
|
+
permissions:
|
|
75
|
+
id-token: write
|
|
76
|
+
environment:
|
|
77
|
+
name: pypi
|
|
78
|
+
url: https://pypi.org/project/imgbytesizer
|
|
79
|
+
steps:
|
|
80
|
+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
81
|
+
name: 📥 Download artifact
|
|
82
|
+
with:
|
|
83
|
+
name: release
|
|
84
|
+
path: dist/
|
|
85
|
+
|
|
86
|
+
- uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
|
|
87
|
+
name: 🚀 Publish package
|
|
88
|
+
with:
|
|
89
|
+
user: __token__
|
|
90
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
91
|
+
|
|
92
|
+
github-release:
|
|
93
|
+
runs-on: ubuntu-latest
|
|
94
|
+
needs:
|
|
95
|
+
- pypi-publish
|
|
96
|
+
permissions:
|
|
97
|
+
contents: write
|
|
98
|
+
id-token: write
|
|
99
|
+
steps:
|
|
100
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
101
|
+
name: ⬇️ Checkout repository
|
|
102
|
+
with:
|
|
103
|
+
fetch-depth: 0
|
|
104
|
+
|
|
105
|
+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
106
|
+
name: 📥 Download artifact
|
|
107
|
+
with:
|
|
108
|
+
name: release
|
|
109
|
+
path: dist/
|
|
110
|
+
|
|
111
|
+
- uses: sigstore/gh-action-sigstore-python@04cffa1d795717b140764e8b640de88853c92acc # v3.3.0
|
|
112
|
+
name: 🔑 Sign artifact
|
|
113
|
+
with:
|
|
114
|
+
inputs: dist/*
|
|
115
|
+
|
|
116
|
+
- name: 🔧 Set TAG_NAME
|
|
117
|
+
run: |
|
|
118
|
+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
|
|
119
|
+
echo "TAG_NAME=${{ github.event.inputs.version_tag }}" >> "$GITHUB_ENV"
|
|
120
|
+
else
|
|
121
|
+
echo "TAG_NAME=${GITHUB_REF##*/}" >> "$GITHUB_ENV"
|
|
122
|
+
fi
|
|
123
|
+
|
|
124
|
+
- name: 🛑 Fail if TAG_NAME is unset
|
|
125
|
+
run: |
|
|
126
|
+
if [[ -z "$TAG_NAME" ]]; then
|
|
127
|
+
echo "TAG_NAME is not set!"
|
|
128
|
+
exit 1
|
|
129
|
+
fi
|
|
130
|
+
|
|
131
|
+
- name: 📝 Generate release notes
|
|
132
|
+
uses: orhun/git-cliff-action@c93ef52f3d0ddcdcc9bd5447d98d458a11cd4f72 # v4.7.1
|
|
133
|
+
id: changelog
|
|
134
|
+
with:
|
|
135
|
+
config: cliff.toml
|
|
136
|
+
args: --latest --strip header
|
|
137
|
+
|
|
138
|
+
- name: 🚀 Create GitHub Release
|
|
139
|
+
env:
|
|
140
|
+
GITHUB_TOKEN: ${{ github.token }}
|
|
141
|
+
BODY: ${{ steps.changelog.outputs.content }}
|
|
142
|
+
run: |
|
|
143
|
+
if gh release view "$TAG_NAME" --repo "$GITHUB_REPOSITORY" > /dev/null 2>&1; then
|
|
144
|
+
gh release edit "$TAG_NAME" --repo "$GITHUB_REPOSITORY" --notes "$BODY"
|
|
145
|
+
gh release upload "$TAG_NAME" dist/* --repo "$GITHUB_REPOSITORY" --clobber
|
|
146
|
+
else
|
|
147
|
+
gh release create "$TAG_NAME" dist/* --repo "$GITHUB_REPOSITORY" --notes "$BODY"
|
|
148
|
+
fi
|
|
149
|
+
|
|
150
|
+
update-changelog:
|
|
151
|
+
runs-on: ubuntu-latest
|
|
152
|
+
needs:
|
|
153
|
+
- github-release
|
|
154
|
+
permissions:
|
|
155
|
+
contents: write
|
|
156
|
+
steps:
|
|
157
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
158
|
+
name: ⬇️ Checkout repository
|
|
159
|
+
with:
|
|
160
|
+
fetch-depth: 0
|
|
161
|
+
ref: main
|
|
162
|
+
|
|
163
|
+
- name: 📝 Generate full changelog
|
|
164
|
+
uses: orhun/git-cliff-action@c93ef52f3d0ddcdcc9bd5447d98d458a11cd4f72 # v4.7.1
|
|
165
|
+
with:
|
|
166
|
+
config: cliff.toml
|
|
167
|
+
args: --output CHANGELOG.md
|
|
168
|
+
|
|
169
|
+
- name: 📤 Commit and push changelog
|
|
170
|
+
run: |
|
|
171
|
+
git config user.name "github-actions[bot]"
|
|
172
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
173
|
+
if git diff --quiet CHANGELOG.md; then
|
|
174
|
+
echo "No changelog changes to commit"
|
|
175
|
+
else
|
|
176
|
+
git add CHANGELOG.md
|
|
177
|
+
git commit -m "docs: update CHANGELOG.md for ${GITHUB_REF##*/}"
|
|
178
|
+
git push origin main
|
|
179
|
+
fi
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
|
|
110
|
+
# pdm
|
|
111
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
112
|
+
#pdm.lock
|
|
113
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
114
|
+
# in version control.
|
|
115
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
116
|
+
.pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
121
|
+
__pypackages__/
|
|
122
|
+
|
|
123
|
+
# Celery stuff
|
|
124
|
+
celerybeat-schedule
|
|
125
|
+
celerybeat.pid
|
|
126
|
+
|
|
127
|
+
# SageMath parsed files
|
|
128
|
+
*.sage.py
|
|
129
|
+
|
|
130
|
+
# Environments
|
|
131
|
+
.env
|
|
132
|
+
.venv
|
|
133
|
+
env/
|
|
134
|
+
venv/
|
|
135
|
+
ENV/
|
|
136
|
+
env.bak/
|
|
137
|
+
venv.bak/
|
|
138
|
+
|
|
139
|
+
# Spyder project settings
|
|
140
|
+
.spyderproject
|
|
141
|
+
.spyproject
|
|
142
|
+
|
|
143
|
+
# Rope project settings
|
|
144
|
+
.ropeproject
|
|
145
|
+
|
|
146
|
+
# mkdocs documentation
|
|
147
|
+
/site
|
|
148
|
+
|
|
149
|
+
# mypy
|
|
150
|
+
.mypy_cache/
|
|
151
|
+
.dmypy.json
|
|
152
|
+
dmypy.json
|
|
153
|
+
|
|
154
|
+
# Pyre type checker
|
|
155
|
+
.pyre/
|
|
156
|
+
|
|
157
|
+
# pytype static type analyzer
|
|
158
|
+
.pytype/
|
|
159
|
+
|
|
160
|
+
# Cython debug symbols
|
|
161
|
+
cython_debug/
|
|
162
|
+
|
|
163
|
+
# PyCharm
|
|
164
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
165
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
166
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
167
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
168
|
+
#.idea/
|
|
169
|
+
|
|
170
|
+
# Ruff stuff:
|
|
171
|
+
.ruff_cache/
|
|
172
|
+
|
|
173
|
+
# PyPI configuration file
|
|
174
|
+
.pypirc
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[style]
|
|
2
|
+
based_on_style = pep8
|
|
3
|
+
indent_width = 2
|
|
4
|
+
column_limit = 100
|
|
5
|
+
split_before_named_assigns = true
|
|
6
|
+
split_before_expression_after_opening_paren = true
|
|
7
|
+
allow_multiline_lambdas = true
|
|
8
|
+
dedent_closing_brackets = true
|
|
9
|
+
coalesce_brackets = false
|
|
10
|
+
split_complex_comprehension = true
|
|
11
|
+
each_dict_entry_on_separate_line = true
|
|
12
|
+
split_before_first_argument = true
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"editor.tabSize": 2,
|
|
3
|
+
"editor.insertSpaces": true,
|
|
4
|
+
"[python]": {
|
|
5
|
+
"editor.tabSize": 2,
|
|
6
|
+
"editor.insertSpaces": true,
|
|
7
|
+
"editor.formatOnSaveMode": "file",
|
|
8
|
+
"editor.formatOnSave": true,
|
|
9
|
+
"editor.defaultFormatter": "eeyore.yapf"
|
|
10
|
+
},
|
|
11
|
+
"sonarlint.connectedMode.project": {
|
|
12
|
+
"connectionId": "pyyupsk",
|
|
13
|
+
"projectKey": "pyyupsk_imgbytesizer"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# This file is used by vulture to mark certain symbols as used,
|
|
2
|
+
# even if they're not explicitly referenced in the code.
|
|
3
|
+
|
|
4
|
+
from unittest.mock import Mock
|
|
5
|
+
|
|
6
|
+
from PIL import ImageFile
|
|
7
|
+
|
|
8
|
+
# Required to allow PIL to load incomplete/truncated images.
|
|
9
|
+
ImageFile.LOAD_TRUNCATED_IMAGES # imgbytesizer/resizer.py
|
|
10
|
+
|
|
11
|
+
_mock = Mock()
|
|
12
|
+
_mock.side_effect # tests/test_main.py
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to imgbytesizer project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.2.5] - 2025-05-25
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Refactored resizer.py for better code organization and maintainability:
|
|
13
|
+
- Split large functions into smaller, focused ones
|
|
14
|
+
- Added new helper functions for better code reuse
|
|
15
|
+
- Improved type hints and documentation
|
|
16
|
+
- Enhanced test coverage with new test cases
|
|
17
|
+
- Improved error handling and edge cases in image processing
|
|
18
|
+
- Enhanced binary search algorithms for better quality/size optimization
|
|
19
|
+
|
|
20
|
+
## [0.2.4] - 2025-05-15
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- Switched to Poetry for dependency management; removed requirements.txt and requirements-dev.txt
|
|
25
|
+
- Added poetry.lock and updated pyproject.toml with [tool.poetry] and dev dependencies
|
|
26
|
+
- Added tox.ini for unified test/lint/typecheck/build automation
|
|
27
|
+
- Updated Makefile to use poetry for build
|
|
28
|
+
- Refactored project structure: all code now under src/imgbytesizer/
|
|
29
|
+
- Updated all scripts, tests, and CI/CD to use new src/ layout
|
|
30
|
+
- Improved and unified GitHub Actions workflows for CI and publishing
|
|
31
|
+
- Removed scripts/sort_requirements.py (no longer needed)
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
|
|
35
|
+
- Path issues in tests and scripts due to src/ layout
|
|
36
|
+
- Minor type hint and formatting tweaks
|
|
37
|
+
|
|
38
|
+
## [0.2.3] - 2025-05-14
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
|
|
42
|
+
- Added ASCII art banner using pyfiglet
|
|
43
|
+
- Added requirements sorting script (`scripts/sort_requirements.py`)
|
|
44
|
+
- Added virtual environment setup in CI workflows
|
|
45
|
+
- Added pyfiglet dependency for banner display
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
|
|
49
|
+
- Switched from mypy to ty for type checking
|
|
50
|
+
- Improved file size formatting with consistent decimal places
|
|
51
|
+
- Reorganized CLI help groups for better readability
|
|
52
|
+
- Enhanced type hints throughout the codebase
|
|
53
|
+
- Improved GitHub Actions workflows with venv setup
|
|
54
|
+
- Updated VS Code extensions recommendations
|
|
55
|
+
|
|
56
|
+
### Fixed
|
|
57
|
+
|
|
58
|
+
- Fixed file size formatting to use consistent decimal places
|
|
59
|
+
- Improved type checking configuration
|
|
60
|
+
|
|
61
|
+
## [0.2.2] - 2025-05-13
|
|
62
|
+
|
|
63
|
+
### Added
|
|
64
|
+
|
|
65
|
+
- New GitHub Actions workflow for running tests (`.github/workflows/test.yml`).
|
|
66
|
+
- Includes steps for checking out repository, setting up Python, installing dependencies, running `pytest` with coverage, uploading coverage to Codecov, and running linters (`flake8`, `mypy`).
|
|
67
|
+
- `.style.yapf` configuration file for YAPF Python formatter.
|
|
68
|
+
- `.vscode/settings.json` to configure editor tab size, insert spaces, and default Python formatter to YAPF for VS Code users.
|
|
69
|
+
- Added `eeyore.yapf` and `ms-python.mypy-type-checker` to VS Code recommended extensions (`.vscode/extensions.json`).
|
|
70
|
+
- Added `indent-size = 2` to `.flake8` configuration.
|
|
71
|
+
- Added entries to `.vulture_ignore.py` for mock objects used in tests.
|
|
72
|
+
- Added Codecov badge to `README.md`.
|
|
73
|
+
|
|
74
|
+
### Changed
|
|
75
|
+
|
|
76
|
+
- **Development Environment & CI:**
|
|
77
|
+
- Updated `Makefile`:
|
|
78
|
+
- `test` target now specifies `tests/` directory and includes coverage flags: `pytest tests/ --cov=imgbytesizer --cov-report=xml`.
|
|
79
|
+
- `lint` target now runs `vulture imgbytesizer scripts tests .vulture_ignore.py`. `flake8 imgbytesizer scripts tests`. `ruff` check removed from this specific target.
|
|
80
|
+
- `format` target now uses `yapf -ir imgbytesizer scripts tests` instead of `ruff check . --fix` and `black .`.
|
|
81
|
+
- Updated VS Code recommended extensions: replaced `ms-python.autopep8` with `ms-python.mypy-type-checker` and added `eeyore.yapf`.
|
|
82
|
+
- **Code Structure & Formatting:**
|
|
83
|
+
- Refactored formatting utilities:
|
|
84
|
+
- Moved `print_progress_bar`, `print_result`, `print_processing_step`, `print_comparison_table` from `imgbytesizer.formatter` to `imgbytesizer.logger`.
|
|
85
|
+
- `imgbytesizer.formatter` now primarily contains the `format_filesize` function.
|
|
86
|
+
- Imports in `imgbytesizer.main` updated to reflect moved utilities.
|
|
87
|
+
- Imports in `imgbytesizer.resizer` updated to reflect moved utilities.
|
|
88
|
+
- **Logging & Output:**
|
|
89
|
+
- `imgbytesizer.logger.py` now also includes utility functions for printing progress bars, results, processing steps, and comparison tables, previously in `formatter.py`.
|
|
90
|
+
- `imgbytesizer.main.py` imports moved functions from `logger.py`.
|
|
91
|
+
|
|
92
|
+
### Removed
|
|
93
|
+
|
|
94
|
+
- Removed `ruff check .` from the `lint` target in `Makefile`.
|
|
95
|
+
- Removed `ruff check . --fix` and `black .` from the `format` target in `Makefile`, replaced by `yapf`.
|
|
96
|
+
- Most formatting utility functions (like `print_progress_bar`, `print_result`, etc.) were removed from `imgbytesizer.formatter.py` as they were relocated to `imgbytesizer.logger.py`.
|
|
97
|
+
|
|
98
|
+
## [0.2.1] - 2025-05-12
|
|
99
|
+
|
|
100
|
+
### Added
|
|
101
|
+
|
|
102
|
+
- Implemented a new combined strategy of image upscaling and quality adjustment to better achieve target file sizes, especially when the original image is smaller than the target (`resizer.py`). This includes the `_try_combined_approach` function.
|
|
103
|
+
- Integrated `pytest` for automated testing, including a new `test` target in `Makefile` and a test execution step in the CI pipeline (`.github/workflows/publish.yml`, `Makefile`).
|
|
104
|
+
- Added `.flake8` configuration file with `max-line-length = 100`.
|
|
105
|
+
|
|
106
|
+
### Changed
|
|
107
|
+
|
|
108
|
+
- **Resizing Core Logic:**
|
|
109
|
+
- Quality adjustment algorithm (`_try_quality_adjustment`, `_find_best_quality`) now uses a wider quality range (1-100, up from 1-95) and increased iterations (e.g., 12 from 10) for more precise results (`resizer.py`).
|
|
110
|
+
- Binary search for optimal quality during resizing has been refined for better accuracy, attempting higher qualities if current size is under target and lower if over (`resizer.py`).
|
|
111
|
+
- Resizing algorithm's (`_try_resizing`) binary search for scale factor now uses more iterations and finer step adjustments for scale (e.g., `high_scale - low_scale > 0.005`) (`resizer.py`).
|
|
112
|
+
- Updated image resampling to use `Image.Resampling.LANCZOS` (modern Pillow API) instead of deprecated `Image.LANCZOS` (`resizer.py`).
|
|
113
|
+
- Fallback image format for output path generation is now 'JPEG' if the original image format is undefined (e.g., `img.format or "JPEG"`) (`resizer.py`).
|
|
114
|
+
- Logic for final adjustment to exact size improved, including handling cases where the image is larger than the target after initial processing by attempting a final quality adjustment (`_final_quality_adjustment` implied) (`resizer.py`).
|
|
115
|
+
- **Development Environment & CI:**
|
|
116
|
+
- Replaced `flake8` with `ruff` for linting (e.g., `ruff check .`) and added `ruff --fix` to the formatting pipeline in `Makefile`.
|
|
117
|
+
- `mypy` type checking and `black` formatting in `Makefile` now target the entire project (`.`) for broader coverage (e.g., `mypy .`, `black .`).
|
|
118
|
+
- Updated Vulture dead code detection paths in `Makefile` to include `scripts` and `tests` directories.
|
|
119
|
+
- CI pipeline (`.github/workflows/publish.yml`):
|
|
120
|
+
- `check-version` job now depends on the successful completion of the `tests` job.
|
|
121
|
+
- Enhanced GitHub Release step to update existing releases if a tag already exists, preventing errors (`gh release view "$TAG_NAME" ... else ... gh release create`).
|
|
122
|
+
- Modified `TAG_NAME` environment variable logic in the publish workflow (`inputs.version_tag || github.ref_name`).
|
|
123
|
+
- **Code Quality & Readability:**
|
|
124
|
+
- Significantly improved type hinting across the codebase for better maintainability and clarity (e.g., `Optional`, `Tuple`, `Union`, `ClassVar`, `Path` in `__init__.py`, `formatter.py`, `logger.py`, `main.py`, `resizer.py`).
|
|
125
|
+
- `format_filesize` utility in `formatter.py` now gracefully handles `None` as input for file size, returning "N/A".
|
|
126
|
+
- **Documentation:**
|
|
127
|
+
- Updated example usage (target size `1MB` from `250KB`) and example output in `README.md` to reflect the new resizing strategies, messages ("Trying combined scaling and quality approach...", "Combined approach success: scale=..."), and performance characteristics.
|
|
128
|
+
|
|
129
|
+
### Fixed
|
|
130
|
+
|
|
131
|
+
- Improved ability to reach target file sizes for images that are initially smaller than the target, due to the new combined upscaling and quality adjustment strategy.
|
|
132
|
+
- Enhanced robustness in determining output image format, particularly when the input image's format is not readily available from its metadata.
|
|
133
|
+
- Ensured progress bars and colored output are correctly suppressed when not in a TTY environment (existing but reinforced by type hints and explicit checks).
|
|
134
|
+
|
|
135
|
+
## [0.2.0] - 2025-05-10
|
|
136
|
+
|
|
137
|
+
### Added
|
|
138
|
+
|
|
139
|
+
- New logging system with proper logger configuration (`logger.py`)
|
|
140
|
+
- Added debug mode with `--debug` flag for detailed error information
|
|
141
|
+
- Added quiet mode with `-q`/`--quiet` flag for minimal output
|
|
142
|
+
- Added version display with `-v`/`--version` flag
|
|
143
|
+
- Support for truncated images via `ImageFile.LOAD_TRUNCATED_IMAGES`
|
|
144
|
+
- Better non-TTY terminal support (no color, no progress bars)
|
|
145
|
+
- Added proper color detection for terminal output
|
|
146
|
+
- Improved error handling throughout the application
|
|
147
|
+
- Added development tools:
|
|
148
|
+
- vulture for dead code detection
|
|
149
|
+
- flake8 for linting
|
|
150
|
+
- mypy for type checking
|
|
151
|
+
- black for code formatting
|
|
152
|
+
|
|
153
|
+
### Changed
|
|
154
|
+
|
|
155
|
+
- Improved CLI interface with better help messages
|
|
156
|
+
- Refined image processing algorithms for better quality and speed
|
|
157
|
+
- Enhanced terminal output formatting with improved progress bars
|
|
158
|
+
- Better filesize formatting with consistent precision
|
|
159
|
+
- Optimized quality adjustment algorithm with more efficient binary search
|
|
160
|
+
- Improved format handling and normalization
|
|
161
|
+
- Code refactoring for better maintainability:
|
|
162
|
+
- Split large functions into smaller, focused ones
|
|
163
|
+
- Better separation of concerns
|
|
164
|
+
- More consistent naming conventions
|
|
165
|
+
- Updated dependencies in requirements-dev.txt
|
|
166
|
+
|
|
167
|
+
### Fixed
|
|
168
|
+
|
|
169
|
+
- Fixed handling of image formats and extensions
|
|
170
|
+
- Fixed potential issues with terminal width detection
|
|
171
|
+
- Improved error messages for better user experience
|
|
172
|
+
- Fixed image quality optimization for different formats
|
|
173
|
+
- Fixed color output detection for various terminal types
|
|
174
|
+
|
|
175
|
+
## [0.1.0] - Initial Release
|
|
176
|
+
|
|
177
|
+
- Initial implementation of imgbytesizer
|
|
178
|
+
- Basic CLI interface
|
|
179
|
+
- Support for resizing images to target file sizes
|
|
180
|
+
- Support for JPG, PNG, and WebP formats
|
|
181
|
+
- Quality optimization for supported formats
|
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: imgbytesizer
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.6
|
|
4
4
|
Summary: A CLI tool to resize images to a target file size.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Requires-Python: >=3.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
-
Requires-Dist: pillow (>=11.2.1,<12.0.0)
|
|
18
|
-
Requires-Dist: pyfiglet (>=1.0.2,<2.0.0)
|
|
19
|
-
Requires-Dist: tabulate (>=0.9.0,<0.10.0)
|
|
5
|
+
Author-email: pyyupsk <contact@fasu.dev>
|
|
6
|
+
License: MIT License
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: cli,compression,image,optimize,resize
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Requires-Dist: pillow<13.0.0,>=12.2.0
|
|
11
|
+
Requires-Dist: pyfiglet<2.0.0,>=1.0.2
|
|
12
|
+
Requires-Dist: tabulate<0.10.0,>=0.9.0
|
|
20
13
|
Description-Content-Type: text/markdown
|
|
21
14
|
|
|
22
15
|
# ImgByteSizer
|
|
@@ -24,6 +17,7 @@ Description-Content-Type: text/markdown
|
|
|
24
17
|
[](https://pypi.org/project/imgbytesizer/)
|
|
25
18
|
[](https://pepy.tech/projects/imgbytesizer)
|
|
26
19
|
[](https://codecov.io/gh/pyyupsk/imgbytesizer)
|
|
20
|
+
[](https://sonarcloud.io/summary/new_code?id=pyyupsk_imgbytesizer)
|
|
27
21
|
|
|
28
22
|
ImgByteSizer is a command-line tool that precisely resizes and optimizes images to match a specific file size while maintaining the best possible quality.
|
|
29
23
|
|
|
@@ -201,4 +195,3 @@ Contributions are welcome! Feel free to submit issues or pull requests.
|
|
|
201
195
|
## License
|
|
202
196
|
|
|
203
197
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
204
|
-
|