-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings_node.py
More file actions
61 lines (55 loc) · 2.9 KB
/
settings_node.py
File metadata and controls
61 lines (55 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""ComfyUI node: produces METADATA_SETTINGS widget-values dict."""
from __future__ import annotations
from typing import Any, Dict, Tuple
from .metadata.locations import list_location_labels, load_locations
from .metadata.profiles import list_profile_labels, load_profiles
class ControlMetadataSettings:
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
profile_choices = ["random"] + list_profile_labels()
location_choices = ["random", "custom (enter lat/lon)"] + [
label for label in list_location_labels() if label != "Custom (enter lat/lon)"
]
return {
"required": {
"profile": (profile_choices, {"default": "iPhone 17 Pro (back camera)"}),
"location": (location_choices, {"default": "random"}),
"write_gps": ("BOOLEAN", {"default": False}),
"custom_lat": ("FLOAT", {"default": 0.0, "min": -90.0, "max": 90.0, "step": 0.0001}),
"custom_lon": ("FLOAT", {"default": 0.0, "min": -180.0, "max": 180.0, "step": 0.0001}),
"custom_tz": ("STRING", {"default": "UTC"}),
"shutter": ("STRING", {"default": "auto"}),
"aperture": ("STRING", {"default": "auto"}),
"iso": ("STRING", {"default": "auto"}),
"focal_length_mm": ("STRING", {"default": "auto"}),
"capture_datetime": ("STRING", {"default": "auto"}),
"processing_offset_hours_min": ("INT", {"default": 4, "min": 0, "max": 720}),
"processing_offset_hours_max": ("INT", {"default": 168, "min": 0, "max": 720}),
"creator": ("STRING", {"default": ""}),
"copyright": ("STRING", {"default": ""}),
"serial_number_mode": (["none", "synthetic"], {"default": "synthetic"}),
"randomize_per": (["image", "batch"], {"default": "image"}),
"edit_intensity": (["light", "medium", "heavy"], {"default": "medium"}),
"seed": ("INT", {"default": 0, "min": 0, "max": 2**31 - 1}),
}
}
RETURN_TYPES: Tuple[str, ...] = ("METADATA_SETTINGS",)
RETURN_NAMES: Tuple[str, ...] = ("metadata_settings",)
FUNCTION = "produce"
CATEGORY = "image"
def produce(self, **widget_values: Any) -> Tuple[Dict[str, Any]]:
profile = widget_values["profile"]
if profile != "random":
for p in load_profiles().values():
if p.label == profile:
widget_values["profile"] = p.id
break
location = widget_values["location"]
if location == "custom (enter lat/lon)":
widget_values["location"] = "custom"
elif location != "random":
for l in load_locations().values():
if l.label == location:
widget_values["location"] = l.id
break
return (dict(widget_values),)