Skip to content

Add optional Python and NumPy bindings - #171

Merged
danoli3 merged 2 commits into
masterfrom
feat/python-numpy
Oct 15, 2026
Merged

danoli3 merged 2 commits into
masterfrom
feat/python-numpy

Conversation

@danoli3

@danoli3 danoli3 commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Add optional Python/NumPy bindings as a separately built package under bindings/python, inspired by FreeImageRe's Python interface. Use ctypes against an installed shared FreeImage library, without adding Python dependencies to the core C/C++ build or copying the interpreter integration.

Provide load/loadf/save and load_bytes/save_bytes with owned top-down RGB/RGBA arrays. Support native-endian uint8/uint16/float32 and scalar float64, palettes/indexed transparency, sliced/reversed arrays, Unicode Windows paths, and clean exceptions. Reject unsupported pixel types, CMYK, big-endian bitmap layouts and header-only arrays explicitly. Each operation frees its bitmap/memory stream; returned arrays never borrow freed library storage. Metadata-to-Python mapping is separate future work.

The package is opt-in, includes FreeImage's license texts, supports FREEIMAGE_LIBRARY overrides, and builds a pure-Python wheel without embedding native binaries. No PyPI publication is performed. Add Linux/macOS/Windows CI that builds a shared library, installs the package, runs tests and uploads a wheel artifact.

Validation: build the wheel locally, install it into an isolated target directory, and run the installed package's four test groups with NumPy 2.2.6. Cover exact RGB/RGBA/grayscale/HDR round trips, memory/file I/O, ownership/writability, noncontiguous/reversed arrays, Unicode filenames and invalid inputs.

PR stack

Depends on #170; base branch is feat/image-analysis-tools. Top of stack.

#165 → #166 → #167 → #168 → #169 → #170 → #171

Merge bottom-up. Each PR diff is relative to its predecessor. Combined stack validation passed locally: 10 CTest suites with ASan, 9 in a shared build, 6 with both optional codecs disabled, plus all four Python/NumPy test groups. GitHub CI reruns after the branch rewrite.

@danoli3
danoli3 merged commit 46c9b4f into master Oct 15, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant