Skip to content

Commit 5d967cd

Browse files
committed
fix: Update the examples
1 parent 42309f5 commit 5d967cd

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

examples/sign.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
fixtures_dir = os.path.join(os.path.dirname(__file__), "../tests/fixtures/")
2727
output_dir = os.path.join(os.path.dirname(__file__), "../output/")
2828

29-
# Ensure the output directory exists
29+
# Ensure the output directory exists.
3030
if not os.path.exists(output_dir):
3131
os.makedirs(output_dir)
3232

@@ -43,7 +43,7 @@
4343
with open(fixtures_dir + "es256_private.key", "rb") as key_file:
4444
key = key_file.read()
4545

46-
# Define a callback signer function
46+
# Define a callback signer function.
4747
def callback_signer_es256(data: bytes) -> bytes:
4848
"""Callback function that signs data using ES256 algorithm."""
4949
private_key = serialization.load_pem_private_key(
@@ -60,7 +60,6 @@ def callback_signer_es256(data: bytes) -> bytes:
6060
# Create a manifest definition as a dictionary.
6161
# This manifest follows the V2 manifest format.
6262
manifest_definition = {
63-
"claim_generator": "python_example",
6463
"claim_generator_info": [{
6564
"name": "python_example",
6665
"version": "0.0.1",
@@ -87,7 +86,7 @@ def callback_signer_es256(data: bytes) -> bytes:
8786
}
8887

8988
# Sign the image with the signer created above,
90-
# which will use the callback signer
89+
# which will use the callback signer.
9190
print("\nSigning the image file...")
9291

9392
with c2pa.Signer.from_callback(
@@ -107,6 +106,9 @@ def callback_signer_es256(data: bytes) -> bytes:
107106
print("\nReading signed image metadata:")
108107
with open(output_dir + "A_signed.jpg", "rb") as file:
109108
with c2pa.Reader("image/jpeg", file) as reader:
109+
# The validation state will depend on loaded trust settings.
110+
# Without loaded trust settings,
111+
# the manifest validation_state will be "Invalid".
110112
print(reader.json())
111113

112114
print("\nExample completed successfully!")

examples/sign_info.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@
100100
print("\nReading signed image metadata:")
101101
with open(output_dir + "C_signed.jpg", "rb") as file:
102102
with c2pa.Reader("image/jpeg", file) as reader:
103+
# The validation state will depend on loaded trust settings.
104+
# Without loaded trust settings,
105+
# the manifest validation_state will be "Invalid".
103106
print(reader.json())
104107

105108
print("\nExample completed successfully!")

0 commit comments

Comments
 (0)