pyimagekit 0.1.0a2__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.
@@ -0,0 +1,35 @@
1
+ name: Publish Package
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*" # This catches both v0.1.0-test and v0.1.0
7
+
8
+ jobs:
9
+ publish-test:
10
+ # Only runs if the tag contains "-test"
11
+ if: contains(github.ref_name, '-test')
12
+ runs-on: ubuntu-latest
13
+ environment: testpypi
14
+ permissions:
15
+ id-token: write
16
+ contents: read
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: astral-sh/setup-uv@v5
20
+ - run: uv build
21
+ - run: uv publish --index testpypi
22
+
23
+ publish-pypi:
24
+ # Only runs if the tag DOES NOT contain "-test"
25
+ if: startsWith(github.ref_name, 'v') && !contains(github.ref_name, '-test')
26
+ runs-on: ubuntu-latest
27
+ environment: pypi
28
+ permissions:
29
+ id-token: write
30
+ contents: read
31
+ steps:
32
+ - uses: actions/checkout@v4
33
+ - uses: astral-sh/setup-uv@v5
34
+ - run: uv build
35
+ - run: uv publish --index pypi
@@ -0,0 +1,18 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ # Test
13
+ tests/**/*.jpg
14
+ tests/**/*.jpeg
15
+ tests/**/text.txt
16
+
17
+ # pypi
18
+ .pypirc
@@ -0,0 +1 @@
1
+ 3.9
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hoopoes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,89 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyimagekit
3
+ Version: 0.1.0a2
4
+ Summary: A Python library that provides a unified interface for handling images across multiple formats and performing common image processing tasks.
5
+ Project-URL: Repository, https://github.com/Hoopoes/pyimagekit
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Classifier: Development Status :: 1 - Planning
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Natural Language :: English
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.7
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.9
23
+ Requires-Dist: numpy>=1.21.6
24
+ Requires-Dist: opencv-python-headless>=4.13.0.92
25
+ Requires-Dist: pillow>=9.5.0
26
+ Requires-Dist: pydantic>=2.5.3
27
+ Provides-Extra: all
28
+ Requires-Dist: pytesseract; extra == 'all'
29
+ Provides-Extra: pytesseract
30
+ Requires-Dist: pytesseract>=0.3.13; extra == 'pytesseract'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # PyImageKit
34
+
35
+ A Python library providing a unified interface for handling images across multiple formats (`bytes`, OpenCV `cv2`, Pillow `Image`) and performing common image processing tasks.
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ pip install pyimagekit
41
+ ```
42
+
43
+ To include OCR support for document uprighting, install with the optional dependency:
44
+
45
+ ```bash
46
+ pip install "pyimagekit[pytesseract]"
47
+ ```
48
+
49
+ ## Quick Start
50
+
51
+ `pyimagekit` centers around the `SmartImage` class, which allows you to seamlessly load, transform, and export images. It implements a fluent interface so operations can be chained.
52
+
53
+ ```python
54
+ from pyimagekit import SmartImage
55
+
56
+ # 1. Load an image
57
+ with open("document.jpg", "rb") as f:
58
+ img = SmartImage.from_bytes(f.read())
59
+
60
+ # Alternatively:
61
+ # img = SmartImage.from_cv2(cv2_image)
62
+ # img = SmartImage.from_pillow(pil_image)
63
+
64
+ # 2. Process the image
65
+ processed_img = (
66
+ img.resize(width=800)
67
+ .rotate(90)
68
+ .ensure_document_portrait()
69
+ )
70
+
71
+ # 3. Export the processed image
72
+ jpeg_bytes = processed_img.to_bytes(format="JPEG", quality=85)
73
+ base64_str = processed_img.to_base64(format="PNG")
74
+ cv2_mat = processed_img.to_cv2()
75
+ pillow_img = processed_img.to_pillow()
76
+ ```
77
+
78
+ ## Features
79
+
80
+ The `SmartImage` class currently supports the following operations:
81
+
82
+ - **Loading:** `from_bytes`, `from_cv2`, `from_pillow`
83
+ - **Exporting:** `to_cv2`, `to_pillow`, `to_bytes`, `to_base64`
84
+ - **Transformations:** `resize`, `crop`, `rotate`, `sharpen_v1`, `sharpen_v2`, `adjust_quality`, `apply` (for custom functions)
85
+ - **Document Processing:** `unwarp_document`, `ensure_document_upright`, `ensure_document_portrait`, `ensure_document_landscape`
86
+
87
+ ## License
88
+
89
+ MIT License
@@ -0,0 +1,57 @@
1
+ # PyImageKit
2
+
3
+ A Python library providing a unified interface for handling images across multiple formats (`bytes`, OpenCV `cv2`, Pillow `Image`) and performing common image processing tasks.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install pyimagekit
9
+ ```
10
+
11
+ To include OCR support for document uprighting, install with the optional dependency:
12
+
13
+ ```bash
14
+ pip install "pyimagekit[pytesseract]"
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ `pyimagekit` centers around the `SmartImage` class, which allows you to seamlessly load, transform, and export images. It implements a fluent interface so operations can be chained.
20
+
21
+ ```python
22
+ from pyimagekit import SmartImage
23
+
24
+ # 1. Load an image
25
+ with open("document.jpg", "rb") as f:
26
+ img = SmartImage.from_bytes(f.read())
27
+
28
+ # Alternatively:
29
+ # img = SmartImage.from_cv2(cv2_image)
30
+ # img = SmartImage.from_pillow(pil_image)
31
+
32
+ # 2. Process the image
33
+ processed_img = (
34
+ img.resize(width=800)
35
+ .rotate(90)
36
+ .ensure_document_portrait()
37
+ )
38
+
39
+ # 3. Export the processed image
40
+ jpeg_bytes = processed_img.to_bytes(format="JPEG", quality=85)
41
+ base64_str = processed_img.to_base64(format="PNG")
42
+ cv2_mat = processed_img.to_cv2()
43
+ pillow_img = processed_img.to_pillow()
44
+ ```
45
+
46
+ ## Features
47
+
48
+ The `SmartImage` class currently supports the following operations:
49
+
50
+ - **Loading:** `from_bytes`, `from_cv2`, `from_pillow`
51
+ - **Exporting:** `to_cv2`, `to_pillow`, `to_bytes`, `to_base64`
52
+ - **Transformations:** `resize`, `crop`, `rotate`, `sharpen_v1`, `sharpen_v2`, `adjust_quality`, `apply` (for custom functions)
53
+ - **Document Processing:** `unwarp_document`, `ensure_document_upright`, `ensure_document_portrait`, `ensure_document_landscape`
54
+
55
+ ## License
56
+
57
+ MIT License
@@ -0,0 +1,98 @@
1
+ **To local install package while developing**
2
+ (Install package)
3
+ uv pip install .[dev] (Locally and also install the development dependencies)
4
+ uv pip install -e .[dev] (In editable mode and also install the development dependencies)
5
+ uv pip install -e .[dev,pytesseract] (In editable mode and also install the development and optional dependencies)
6
+
7
+ **How to publish package using uv**
8
+
9
+ [building-your-package](https://docs.astral.sh/uv/guides/package/#building-your-package)
10
+
11
+ [packaging-projects](https://packaging.python.org/en/latest/tutorials/packaging-projects/)
12
+
13
+ **Package stats**
14
+ [PyPiStats](https://pypistats.org)
15
+
16
+ **test**
17
+ uv run --python 3.9 pytest
18
+ uv run --python 3.10 pytest
19
+ ... so on
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+ ## Development & Release Workflow
34
+
35
+ ### 1. Testing (TestPyPI)
36
+ Use this when you want to verify the package builds correctly and can be installed via pip.
37
+
38
+ * **Version:** Update `version` in `pyproject.toml` to an alpha/beta (e.g., `0.1.0a1`).
39
+ * **Branch:** `test`
40
+ * **Commands:**
41
+ ```bash
42
+ # 1. Commit your changes
43
+ git add .
44
+ git commit -m "feat: <description of change>"
45
+
46
+ # 2. Create the test tag
47
+ git tag v0.0.1a1-test
48
+
49
+ # 3. Push the branch first (if code already pushed then no need)
50
+ git push origin test
51
+
52
+ # 4. Push the tag to GitHub
53
+ git push origin v0.0.1a1-test
54
+ ```
55
+ *Result: Automatically builds and publishes to [TestPyPI](https://test.pypi.org/).*
56
+
57
+ ---
58
+
59
+ ### 2. Official Release (PyPI)
60
+ Use this only when the code is stable and ready for public use.
61
+
62
+ * **Version:** Update `version` in `pyproject.toml` to a stable version (e.g., `0.1.0`).
63
+ * **Branch:** `main` (Merge from `test` first).
64
+ * **Commands:**
65
+ ```bash
66
+ # 1. Merge changes into main
67
+ git checkout main
68
+ git merge test
69
+
70
+ # 2. Tag the version (Must match pyproject.toml)
71
+ git tag v0.1.0
72
+
73
+ # 3. Push code and tags
74
+ git push origin main --tags
75
+ ```
76
+ *Result: Automatically builds and publishes to [PyPI](https://pypi.org/).*
77
+
78
+ ---
79
+
80
+ ### 3. Commit Message Standards
81
+ We follow **Conventional Commits** to keep the history clean:
82
+
83
+ | Prefix | Use Case | Example |
84
+ | :---------- | :-------------------------- | :--------------------------------------- |
85
+ | `feat:` | A new feature | `feat: add opencv-based blurring` |
86
+ | `fix:` | A bug fix | `fix: resolve numpy overflow in scaling` |
87
+ | `docs:` | Documentation changes | `docs: update dev.md with release flow` |
88
+ | `chore:` | Maintenance/Version bump | `chore: bump version to 0.1.0` |
89
+ | `refactor:` | Code cleanup (no new logic) | `refactor: simplify internal loop` |
90
+
91
+ ---
92
+
93
+ ### Local Sanity Check
94
+ Always run a local build before pushing to ensure `hatchling` (the build backend) is happy:
95
+ ```bash
96
+ uv build
97
+ ```
98
+ *Verify that the `.whl` and `.tar.gz` files appear in the `dist/` folder.*
@@ -0,0 +1,56 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "pyimagekit"
7
+ version = "0.1.0a2"
8
+ description = "A Python library that provides a unified interface for handling images across multiple formats and performing common image processing tasks."
9
+ readme = "README.md"
10
+ license = 'MIT'
11
+ license-files = ['LICENSE']
12
+ classifiers = [
13
+ "Development Status :: 1 - Planning",
14
+ "Intended Audience :: Developers",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Operating System :: OS Independent",
17
+ "Programming Language :: Python :: 3 :: Only",
18
+ "Programming Language :: Python :: 3.7",
19
+ "Programming Language :: Python :: 3.8",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Topic :: Software Development :: Libraries :: Python Modules",
25
+ "Typing :: Typed",
26
+ "Natural Language :: English",
27
+ ]
28
+ requires-python = ">=3.9"
29
+ dependencies = [
30
+ "numpy>=1.21.6",
31
+ "opencv-python-headless>=4.13.0.92",
32
+ "pillow>=9.5.0",
33
+ "pydantic>=2.5.3",
34
+ ]
35
+
36
+ [project.optional-dependencies]
37
+ pytesseract = ["pytesseract>=0.3.13"]
38
+ all = ["pytesseract"]
39
+
40
+ [dependency-groups]
41
+ dev = ["pytest>=7.4.4"]
42
+
43
+ [project.urls]
44
+ Repository = "https://github.com/Hoopoes/pyimagekit"
45
+
46
+ [[tool.uv.index]]
47
+ name = "testpypi"
48
+ url = "https://test.pypi.org/simple/"
49
+ publish-url = "https://test.pypi.org/legacy/"
50
+ explicit = true
51
+
52
+ [[tool.uv.index]]
53
+ name = "pypi"
54
+ url = "https://pypi.org/simple/"
55
+ publish-url = "https://upload.pypi.org/legacy/"
56
+ explicit = true
@@ -0,0 +1,17 @@
1
+ from .smart_image import (
2
+ ImageFormat,
3
+ SmartImage,
4
+ ImageEmpty,
5
+ ImageTooLarge,
6
+ InvalidImage,
7
+ InvalidAngle,
8
+ )
9
+
10
+ __all__ = [
11
+ "ImageFormat",
12
+ "SmartImage",
13
+ "ImageEmpty",
14
+ "ImageTooLarge",
15
+ "InvalidImage",
16
+ "InvalidAngle",
17
+ ]