forked from AcademySoftwareFoundation/openexr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite python bindings with pybind11 and numpy
This introduces an entirely new python API for reading and writing OpenEXR files that supports all file features (or will soon): scanline, tiled, deep, multi-part, etc. It uses numpy arrays for pixel data, and it supports both separate arrays for each channel and interleaving of RGB data into a single composite channel. It leaves the existing binding API in place for backwards-compatibility; there's no overlap between the two APIs. See src/wrappers/python/README.md for examples of the new API. The API is simple: the ``File`` object holds a py::list of ``Part`` objects, each of which has a py::dict for the header and a py::dict for the channels, and each channels hold a numpy array for the pixel data. There's intentionally no support for selective scanline/time reading; reading a file reads the entire channel data for all parts. There *is*, however, an option to read just the headers and skip the pixel data entirely. A few things don't work yet: - Reading and writing of deep data isn't finished. - ID manfest attributes aren't supported yet. - For mipmaped images, it current only reads the top level. This also does not (yet) properly integrate the real Imath types. It leaves in place for now the internal "Imath.py" module, but defines its own internal set of set of Imath classes. This needs to be resolve once the Imath bindings are distributed via pypi.org The test suite downloads images from openexr-images and runs them through a battery of reading/writing tests. Currently, the download is enabled via the ``OPENEXR_TEST_IMAGE_REPO`` environment variable that is off by default but is on in the python wheel CI workflow. Signed-off-by: Cary Phillips <[email protected]>
- Loading branch information
Showing
18 changed files
with
4,067 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright Contributors to the OpenColorIO Project. | ||
|
||
set -ex | ||
|
||
PYBIND11_VERSION="$1" | ||
|
||
if [[ $OSTYPE == "msys" ]]; then | ||
SUDO="" | ||
else | ||
SUDO="sudo" | ||
fi | ||
|
||
git clone https://github.com/pybind/pybind11.git | ||
cd pybind11 | ||
|
||
if [ "$PYBIND11_VERSION" == "latest" ]; then | ||
LATEST_TAG=$(git describe --abbrev=0 --tags) | ||
git checkout tags/${LATEST_TAG} -b ${LATEST_TAG} | ||
else | ||
git checkout tags/v${PYBIND11_VERSION} -b v${PYBIND11_VERSION} | ||
fi | ||
|
||
mkdir build | ||
cd build | ||
cmake -DCMAKE_BUILD_TYPE=Release \ | ||
-DPYBIND11_INSTALL=ON \ | ||
-DPYBIND11_TEST=OFF \ | ||
../. | ||
$SUDO cmake --build . \ | ||
--target install \ | ||
--config Release \ | ||
--parallel 2 | ||
|
||
cd ../.. | ||
rm -rf pybind11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.