Skip to content

Commit

Permalink
Add support for URI transfer function
Browse files Browse the repository at this point in the history
Currently does nothing except store the URI.

No tests added yet.
  • Loading branch information
ThomasWilshaw committed Sep 28, 2024
1 parent c4ae85c commit 4b0291d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
18 changes: 18 additions & 0 deletions tcolour/TransferCharacteristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,21 @@ def valid(self) -> bool:

def __repr__(self) -> str:
return "TransferCharacteristicPower(sequence=%r)" % (self.sequence)

class TransferCharacteristicURI(TransferCharacteristic):
"""A transfer characteristic that references an external file"""

def __init__(self, URI) -> None:
self.URI = URI

def forward_transfer(self, data):
print("ERROR: You didn't think I'd written my own LUT engine yet did you?")

def inverse_transfer(self,data):
print("ERROR: You didn't think I'd written my own LUT engine yet did you?")

def valid(self) -> bool:
return True

def __repr__(self) -> str:
return "TransferCharacteristicURI(URI=%r)" % (self.URI)
7 changes: 6 additions & 1 deletion tcolour/tcolour.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import yaml
import Colourimetry
import TransferCharacteristic
import uritools

class TColor():
"""Contains a set of known colour spaces. Allows for interacting with and
Expand Down Expand Up @@ -46,7 +47,10 @@ def transfer_charactersitc_from_YAML(self, yaml_input):
return TransferCharacteristic.TransferCharacteristicSequence(yaml_input[1]["Sequence"])

elif tc_type == "URI":
raise ValueError("Transfer Characteristic type URI not yet supported", yaml_input)
if uritools.isuri(yaml_input[1]["URI"]):
return TransferCharacteristic.TransferCharacteristicURI(yaml_input[1]["URI"])
else:
raise ValueError("YAML ERROR, invalid URI: ", yaml_input)

else:
raise ValueError("YAML ERROR, invald Transfer Characteristic type: ", yaml_input)
Expand Down Expand Up @@ -118,4 +122,5 @@ def add_colour_space(self, colour_space):

for key, value in config.config.items():
print(key, value)
print()
pass
2 changes: 1 addition & 1 deletion tests/files/tcolor_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
- Sonfu Custom InHouse Transfer:
Transfer Characteristic:
- Type: URI
- URI: Sonfu-1D.spi1d
- URI: file:Sonfu-1D.spi1d

# Append aliases to the previous definition
- sRGB Presentation:
Expand Down

0 comments on commit 4b0291d

Please sign in to comment.