Dynamic Desktop HEIC¶
quiltwright.dynamic
¶
Apple Dynamic Desktop HEIC packer.
A Dynamic Desktop is one HEIF file holding several stills plus XMP on
image 0 that tells macOS which frame to show. The payload is a base64
binary plist in the apple_desktop namespace:
apr-- light/dark appearance (two frames)solar-- sun altitude/azimuth (any number of frames)h24-- fraction of the local day (any number of frames)
None of this is POV-Ray's clock. That identifier is POV-Ray's
animation parameter (+K / Clock=): it steps a scene through
an internal 0-1 (or Initial_Clock-Final_Clock) loop. It has
nothing to do with the Mac's wall clock or the sun. Real time of day
lives only in this metadata, which macOS reads against Location Services
(solar) or the system clock (h24).
Frames are finished RGB stills -- woven _native_ holograms or ordinary
2D renders. Woven frames encode lossless with 4:4:4 chroma; photographic
HEVC 4:2:0 would mix the per-channel views and destroy the weave.
Typical usage::
from quiltwright.dynamic import AppearanceMap, DynamicSpec, save_dynamic_heic
spec = DynamicSpec.from_appearance(light_rgb, dark_rgb, lossless=True)
save_dynamic_heic(spec, "scene.heic")
Part of Quiltwright -- https://github.com/Flux-Frontiers/quiltwright Author: Eric G. Suchanek, PhD
AppearanceMap(light=0, dark=1)
dataclass
¶
Image indices for System Settings Light / Dark (static).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
light
|
int
|
Index of the light-appearance frame. |
0
|
dark
|
int
|
Index of the dark-appearance frame. |
1
|
DynamicSpec(frames, appearance, solar=(), times=(), lossless=False)
dataclass
¶
Frames plus the metadata that makes a HEIC a Dynamic Desktop.
Exactly one of solar or times may be set; if both are empty this is appearance-only. appearance is always required (solar/h24 files still need Light/Dark fallbacks).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frames
|
tuple[ndarray, ...]
|
RGB |
required |
appearance
|
AppearanceMap
|
Light/Dark fallbacks. |
required |
solar
|
tuple[SolarItem, ...]
|
Solar anchors, or |
()
|
times
|
tuple[TimeItem, ...]
|
Time-of-day anchors, or |
()
|
lossless
|
bool
|
Encode without HEVC 4:2:0. Required for woven frames. |
False
|
from_appearance(light, dark, *, lossless=False)
classmethod
¶
Two-frame Light/Dark wallpaper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
light
|
ndarray
|
RGB frame for light appearance. |
required |
dark
|
ndarray
|
RGB frame for dark appearance. |
required |
lossless
|
bool
|
See the class docstring. |
False
|
Returns:
| Type | Description |
|---|---|
DynamicSpec
|
An appearance-only spec. |
Source code in src/quiltwright/dynamic.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
SolarItem(index, altitude, azimuth)
dataclass
¶
One solar anchor: which frame to show at this sun position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Frame index in the HEIC. |
required |
altitude
|
float
|
Sun altitude in degrees (horizon = 0, zenith = 90). |
required |
azimuth
|
float
|
Sun azimuth in degrees, |
required |
TimeItem(index, time)
dataclass
¶
One time-of-day anchor: which frame to show at this fraction of the day.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Frame index in the HEIC. |
required |
time
|
float
|
Fraction of the local day, |
required |
appearance_plist(mapping)
¶
Binary plist for apple_desktop:apr.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mapping
|
AppearanceMap
|
Light/Dark image indices. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
Apple binary property list bytes. |
Source code in src/quiltwright/dynamic.py
206 207 208 209 210 211 212 | |
is_woven_stem(stem)
¶
Whether stem names a woven native frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stem
|
str
|
Filename without its extension. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in src/quiltwright/dynamic.py
55 56 57 58 59 60 61 | |
metadata_for(spec)
¶
Pick the XMP tag and plist for spec.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
DynamicSpec
|
A validated spec. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, bytes]
|
|
Source code in src/quiltwright/dynamic.py
270 271 272 273 274 275 276 277 278 279 280 | |
parse_clock_time(value)
¶
Parse HH:MM or HH:MM:SS to a fraction of a 24-hour day.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
A wall-clock time, 24-hour. |
required |
Returns:
| Type | Description |
|---|---|
float
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the string is not a time, or is out of range. |
Source code in src/quiltwright/dynamic.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
read_dynamic_metadata(path)
¶
Decode apple_desktop metadata from a Dynamic Desktop HEIC.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
A |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The decoded plist as a plain dict, plus |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If pillow-heif is not installed. |
ValueError
|
If no |
Source code in src/quiltwright/dynamic.py
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | |
save_dynamic_heic(spec, path)
¶
Write a Dynamic Desktop HEIC.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
DynamicSpec
|
Frames and metadata. |
required |
path
|
str | Path
|
Output path ( |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The written path. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If pillow-heif is not installed. |
ValueError
|
If spec is invalid. |
Source code in src/quiltwright/dynamic.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | |
solar_plist(items, appearance)
¶
Binary plist for apple_desktop:solar.
Matches the decoded shape of Apple's The Lake.heic: ap fallbacks
plus si anchors with i / a / z.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items
|
tuple[SolarItem, ...]
|
Solar anchors, in any order. |
required |
appearance
|
AppearanceMap
|
Light/Dark fallbacks. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
Apple binary property list bytes. |
Source code in src/quiltwright/dynamic.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
spec_from_json(path, *, lossless=None)
¶
Load a wallpapper-shaped JSON description.
Each entry needs fileName. Solar entries add altitude and
azimuth; time entries add time (HH:MM or HH:MM:SS).
isPrimary puts that frame at index 0 (Preview's still).
isForLight / isForDark set the appearance fallbacks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
JSON file. Image paths are relative to its directory. |
required |
lossless
|
bool | None
|
See :func: |
None
|
Returns:
| Type | Description |
|---|---|
DynamicSpec
|
A :class: |
Source code in src/quiltwright/dynamic.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | |
spec_from_paths(paths, *, appearance, solar=(), times=(), lossless=None)
¶
Build a spec from still files on disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
list[Path]
|
Frame files, in HEIC order. |
required |
appearance
|
AppearanceMap
|
Light/Dark fallbacks. |
required |
solar
|
tuple[SolarItem, ...]
|
Solar anchors, or empty. |
()
|
times
|
tuple[TimeItem, ...]
|
Time-of-day anchors, or empty. |
()
|
lossless
|
bool | None
|
|
None
|
Returns:
| Type | Description |
|---|---|
DynamicSpec
|
A :class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a woven frame would be lossy-encoded. |
Source code in src/quiltwright/dynamic.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |
time_plist(items, appearance)
¶
Binary plist for apple_desktop:h24.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items
|
tuple[TimeItem, ...]
|
Time-of-day anchors. |
required |
appearance
|
AppearanceMap
|
Light/Dark fallbacks. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
Apple binary property list bytes. |
Source code in src/quiltwright/dynamic.py
232 233 234 235 236 237 238 239 240 241 242 243 | |
validate_spec(spec)
¶
Raise ValueError if spec cannot be a Dynamic Desktop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
DynamicSpec
|
The spec to check. |
required |
Source code in src/quiltwright/dynamic.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
xmp_payload(tag, plist_bytes)
¶
XMP packet wrapping a base64 plist as apple_desktop:<tag>.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
str
|
|
required |
plist_bytes
|
bytes
|
Binary plist from the matching |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
UTF-8 XMP packet. |
Source code in src/quiltwright/dynamic.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |