Skip to main content

Python wrapper around TinyEXR and stb_image

Project description

Simple Image IO

A very simple C# and Python wrapper to read and write RGB images from / to various file formats. Supports .exr via tinyexr and a number of other formats (including .png, .jpg, .bmp) via stb_image and stb_image_write.

Download from Nuget:

Installation via pip:

pip install simpleimageio

Dependencies

All dependencies are header-only. Building requires

  • a C++11 (or newer) compiler
  • CMake
  • .NET 5.0 (or newer)
  • Python ≥ 3.6

Building the C# wrapper on x86-64 Windows, Linux, or macOS

Build the C++ low level library by running:

mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release
cd ..

To compile and run the tests (optional):

dotnet test

That's it. Simply add a reference to SimpleImageIO/SimpleImageIO.csproj to your project and you should be up and running.

Building the C# wrapper on other platforms

In theory, the package works on any platform. However, the native dependencies have to be built for each. Currently, the workflow has been set up and tested for x86-64 versions of Windows, Linux (Ubuntu 20.04) and macOS 10.15. Other platforms need to be built from source. For these, the SimpleImageIO.csproj file needs to be adjusted, instructions can be found in the comments of that file. The process should be a simple copy&paste operation, provided nothing goes south when building the C++ library.

Building the Python wrapper

Simply running:

python -m build

will automatically fetch an adequate version of CMake, compile the shared library, and build the Python package. You can then simply install the result via:

pip install ./dist/SimpleImageIO-*.whl

Usage example (C#)

The following creates a one pixel image and writes it to various file formats:

RgbImage img = new(width: 1, height: 1);
img.SetPixel(0, 0, new(0.1f, 0.4f, 0.9f));
img.WriteToFile("test.exr");
img.WriteToFile("test.png");
img.WriteToFile("test.jpg");

Reading an image from one of the supported formats is equally simple:

RgbImage img = new("test.exr");
Console.WriteLine(img.GetPixel(0, 0).X);

Usage example (Python)

The following creates a one pixel image and writes it to various file formats:

import simpleimageio as sio
sio.write("test.exr", [[[0.1, 0.4, 0.9]]])
sio.write("test.png", [[[0.1, 0.4, 0.9]]])
sio.write("test.jpg", [[[0.1, 0.4, 0.9]]])

Reading an image from one of the supported formats is equally simple:

img = sio.read("test.exr")
print(img[0,0,0])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SimpleImageIO-0.2.3.tar.gz (187.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

SimpleImageIO-0.2.3-cp38-cp38-win_amd64.whl (240.4 kB view details)

Uploaded CPython 3.8Windows x86-64

File details

Details for the file SimpleImageIO-0.2.3.tar.gz.

File metadata

  • Download URL: SimpleImageIO-0.2.3.tar.gz
  • Upload date:
  • Size: 187.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6rc1

File hashes

Hashes for SimpleImageIO-0.2.3.tar.gz
Algorithm Hash digest
SHA256 9ed777dec0c4895d88fbd0b16a8b574281111436bbe5177c0fa008eed614daae
MD5 bde661e42307df43f581928763db8e55
BLAKE2b-256 431b8ed7f228589b54185cd07abb09663796a3f44382a563378e3326f1125852

See more details on using hashes here.

File details

Details for the file SimpleImageIO-0.2.3-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: SimpleImageIO-0.2.3-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 240.4 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6rc1

File hashes

Hashes for SimpleImageIO-0.2.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 4cc287eab12de5a3ae09c1ac6d1d0894a7850c54ef8a4e648fbe50d53667b58f
MD5 95f3d0b51a57c37b01416f1a0b4a6504
BLAKE2b-256 0b628c8797d6a403054c591be2c7bd385dd0a0dd7a3becdd3a2b9b03d20be9eb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page