You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is basically a Python binding for tinyexr. Use CMake to build the module (uses pybind11). Installation script is not there, you can simply copy the resulting python module files. Supports loading functionality, saving can be easily added (pull requests welcome!).
Usage
In the first example we show how to read an EXR image and display an EXR image with matplotlib.
fromtinyexrimportPyEXRImageimportmatplotlib.pyplotaspltimportnumpyasnp# The image in (A)BGR orderimg=PyEXRImage('./figures/dwsample.exr')
print(img)
img_np=np.reshape(np.array(img, copy=False), (img.height, img.width, 4))[:,:,1:]
# Re-order the image to RGB img_np=img_np[...,::-1]
plt.imshow(img_np)
plt.show()
The output image is the following:
In the following sample we demonstrate how to get access to pixel values and display an EXR image with PIL.
fromtinyexrimportPyEXRImage# Load an EXR image (tinyexr backend)img=PyEXRImage('./figures/2by2.exr')
# Print basic detailsprint(img)
# Pixel values accessr=img.getPixel(x,y,0)
g=img.getPixel(x,y,1)
b=img.getPixel(x,y,2)
a=img.getPixel(x,y,3)
# Numpy:m=np.array(img, copy=False)
# orrgb=np.reshape(np.array(rgb_img, copy=False), (rgb_img.height, rgb_img.width, 4))
# a matrix of (height x width x channels)# DisplayfromPILimportImageImage.fromarray(np.clip(np.uint8(rgb*255.0), 0, 255)).show()
PyPI package
Warning: pytinyexr package is old. We are in transit from pytinyexr(v1) to tinyexr(v2).
For a while you are welcome to use git version(Python 3.8+ required)
(pip install git+https://github.com/syoyo/pytinyexr)