Skip to content

Commit

Permalink
encourage contextmanager interface in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianPugh committed Mar 14, 2024
1 parent 4fc322f commit 379a05c
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@ __Simple files__
~~~python
import pyexr

file = pyexr.open("color.exr")
with pyexr.open("color.exr") as file:
file.channels # [R, G, B]
file.width # 1280
file.height # 720
file.channel_precision["R"] # pyexr.FLOAT

file.channels # [R, G, B]
file.width # 1280
file.height # 720
file.channel_precision["R"] # pyexr.FLOAT

img = file.get() # (720,1280,3) np.float32 array
img = file.get(precision=pyexr.HALF) # (720,1280,3) np.float16 array
red = file.get("R") # (720,1280,1) np.float32 array
red = file.get("R", precision=pyexr.HALF) # (720,1280,1) np.float16 array
img = file.get() # (720,1280,3) np.float32 array
img = file.get(precision=pyexr.HALF) # (720,1280,3) np.float16 array
red = file.get("R") # (720,1280,1) np.float32 array
red = file.get("R", precision=pyexr.HALF) # (720,1280,1) np.float16 array

~~~

Expand All @@ -39,18 +38,17 @@ __Fat / Multi-channel EXRs__
~~~python
import pyexr

file = pyexr.open("multi-channel.exr")

file.channels # [R, G, B, A, Variance.R, Variance.G, Variance.B]
file.width # 1280
file.height # 720
with pyexr.open("multi-channel.exr") as file:
file.channels # [R, G, B, A, Variance.R, Variance.G, Variance.B]
file.width # 1280
file.height # 720

all = file.get() # (720,1280,7) np.float32 array (R,G,B,A,Var..)
var = file.get("Variance") # (720,1280,3) np.float32 array
col = file.get("default") # (720,1280,4) np.float32 array (R,G,B,A)
file.channel_map['default'] # ['R','G','B','A']
all = file.get() # (720,1280,7) np.float32 array (R,G,B,A,Var..)
var = file.get("Variance") # (720,1280,3) np.float32 array
col = file.get("default") # (720,1280,4) np.float32 array (R,G,B,A)
file.channel_map['default'] # ['R','G','B','A']

var_r = file.channel("Variance.R") # (720,1280,3) np.float32 array
var_r = file.channel("Variance.R") # (720,1280,3) np.float32 array
~~~


Expand Down

0 comments on commit 379a05c

Please sign in to comment.