AcademySoftwareFoundation / AcademySoftwareFoundation/OpenImageIO

Frame on Frame RAM Increase Using PyBindings for 3.1.0 Converting EXR To Uncompressed PNG

Open
#4,613 1 comment 0 reactions 0 assignees View on GitHub
bug good first issue
Dominant language
C++
Stars
2.4k
Forks
698
Avg merge
2d 23h
Merged PRs (30d)
46

Description

I'm using the Python Bindings for 3.1.0 with Python 3.10.6 on Windows and getting increasing RAM usage with the script below which converts exrs to pngs - about 1Gb for every frame processed. For context, the original .exr is circa 20k x 2k so is pretty large. This doesn't seem to be a problem for oiiotool.exe (3.1.0) which does the same process perfectly with no increase in RAM usage frame by frame. It's also not a problem if I convert from .exr to .tiff so it does seem to be specific to png. Obvious answer is to switch from png to tiff which I will do but felt I should at least make a record of this here.

```
import OpenImageIO as oiio

def convert_exr_to_png(exr_file, png_file):
# Open the EXR file
input_image = oiio.ImageInput.open(exr_file)
if not input_image:
print("Error opening EXR file:", oiio.geterror())
return

# Read the image data
spec = input_image.spec()
pixels = input_image.read_image()
input_image.close()

# Create the output PNG file
output_image = oiio.ImageOutput.create(png_file)
if not output_image:
print("Error creating PNG file:", oiio.geterror())
return

# Set the compression level to 0 (no compression)
spec.attribute("png:compressionLevel", 0)
spec.attribute("png:filter", 8)
#spec.attribute("oiio:ColorSpace", "sRGB")

# Open the output PNG file
output_image.open(png_file, spec)

# Write the image data to the PNG file
output_image.write_image(pixels)

# Close the output image
output_image.close()
pixels = None
print(f"Successfully converted {exr_file} to {png_file} with no compression.")

for x in range(1, 2701):
frame = str(x).zfill(4)
exr = f"//flabby/jobs/client_62185/build/virtual_set/comps/openimage/stitchhalfres/stitch_v021.{frame}.exr"
png = f"//flabby/jobs/client_62185/build/virtual_set/comps/openimage/stitchdebug/stitchcspace_v021.{frame}.png"
convert_exr_to_png(exr, png)
print("Processed Frame: ", x)
```

Contributor guide

Open the contributing guide

Research direction

Start with the supplied Python conversion script and reproduce repeated EXR-to-uncompressed-PNG conversions on Windows, comparing memory use with EXR-to-TIFF and oiiotool.exe. Investigate the Python binding and PNG path to determine why RAM grows between frames; done means identifying the cause and confirming stable memory across repeated conversions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.