Skip to content

Commit 8985319

Browse files
committed
update: header를 EXRHeader로 수정하고 내부를 구현하다*
- raw data들을 property method를 사용하여 순수 python code로 다시 wrapping
1 parent baff6bd commit 8985319

File tree

3 files changed

+57
-4
lines changed

3 files changed

+57
-4
lines changed

openexr_python/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
from .exr_enums import *
1313
from .exr_channel_info import *
1414
from .exr_channel_sampling_rate import *
15-
from openexr_python.header import Header
15+
from .exr_header import *
1616
from .exr_window import *

openexr_python/exr_header.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
from dataclasses import dataclass
2+
from typing import Any, Dict, Tuple
3+
from openexr_python.exr_enums import EXRCompressionType, EXRLineOrderType
4+
from openexr_python.exr_channel_info import EXRChannelInfo
5+
from openexr_python.exr_window import EXRWindow
6+
7+
8+
@dataclass
9+
class EXRHeader:
10+
_header_raw_dict: Dict[str, Any]
11+
12+
def __getitem__(self, key: str) -> Any:
13+
return self._header_raw_dict[key]
14+
15+
@property
16+
def channels(self) -> Dict[str, EXRChannelInfo]:
17+
raw_channels: Dict[str, Any] = self["channels"]
18+
return {
19+
key: EXRChannelInfo.parse_raw2pyobj(raw_channel_info=value)
20+
for key, value in raw_channels.items()
21+
}
22+
23+
@property
24+
def compression(self) -> EXRCompressionType:
25+
raw_compression: Any = self["compression"]
26+
return EXRCompressionType.parse_raw2pyobj(raw_compression=raw_compression)
27+
28+
@property
29+
def data_window(self) -> EXRWindow:
30+
raw_dataWindow: Any = self["dataWindow"]
31+
return EXRWindow.parse_raw_to_window(raw_dataWindow)
32+
33+
@property
34+
def display_window(self) -> EXRWindow:
35+
raw_dataWindow: Any = self["displayWindow"]
36+
return EXRWindow.parse_raw_to_window(raw_dataWindow)
37+
38+
@property
39+
def lineOrder(self) -> EXRLineOrderType:
40+
raw_line_order: Any = self["lineOrder"]
41+
return EXRLineOrderType.parse_raw2pyobj(raw_line_order=raw_line_order)
42+
43+
@property
44+
def pixelAspectRatio(self) -> float:
45+
raw_pixel_aspect_ratio: float = self["pixelAspectRatio"]
46+
return raw_pixel_aspect_ratio
47+
48+
@property
49+
def screenWindowCenter(self) -> Tuple[float, float]:
50+
raw_screen_window_center: Any = self["screenWindowCenter"]
51+
return (raw_screen_window_center.x, raw_screen_window_center.y)
52+
53+
@property
54+
def screenWindowWidth(self) -> float:
55+
raw_screen_window_width: float = self["screenWindowWidth"]
56+
return raw_screen_window_width

openexr_python/header.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)