Files
Eric Rollei 1f9fa9b670 Add backward compatibility, XMP regions, per-node hooks toggle, and enhancements
Major Features:
- Backward compatibility: VALIDATE_INPUTS handles old boolean True/False values for enable_runtime_hooks parameter
- Phase 3: XMP region metadata with MWG-RS compliance (faces, areas, coordinates, extensions)
- Phase 4.4: Per-node UI toggle for runtime hooks (dropdown: Auto/Enabled/Disabled)
- Runtime hooks enhancements: performance tracking, disagreement logging, configurable limits

New Files:
- config.json: Configuration file for runtime hooks and metadata settings
- eric_metadata/hooks/runtime_capture.py: Runtime hook infrastructure
- eric_metadata/utils/config.py: Configuration loader with priority system
- eric_metadata/utils/version.py: Version helper for generated_by labels
- eric_metadata/utils/a1111.py: Automatic1111 parameter string generation
- eric_metadata/utils/jpeg_fallback.py: 4-stage JPEG metadata fallback
- eric_metadata/workflow/: Workflow parsing and generation helpers
- tests/test_backward_compatibility.py: 7 tests for parameter migration
- tests/test_xmp_regions.py: 6 tests for XMP region round-trip
- tests/test_per_node_runtime_hooks.py: 9 tests for per-node toggle

Documentation:
- CONFIG_GUIDE.md: Configuration options and usage
- RUNTIME_HOOKS_QUICK_REFERENCE.md: Quick reference for runtime hooks
- RUNTIME_HOOKS_ENHANCEMENTS_SUMMARY.md: Detailed enhancement documentation
- SAFE_RUNTIME_HOOKS_RESEARCH.md: Safety analysis and validation
- edit_log.md: Complete change history

Test Results: All 143 tests passing
- 7 backward compatibility tests
- 6 XMP region tests
- 9 per-node toggle tests
- 17 runtime hooks enhancement tests
- 104 existing tests

Breaking Changes: None - fully backward compatible
2025-11-20 01:26:04 -08:00

22 lines
2.0 KiB
Markdown

# JPEG Metadata Touchpoints (2025-11-15)
This note captures the current write-paths for JPEG exports in `nodes/eric_metadata_save_image_v099d.py` so the staged fallback work can begin with a clear map of where metadata is injected.
## Primary save call (`save_with_metadata`)
- After the JPEG image is written, metadata embedding is triggered inside the `enable_metadata` check by calling `self.metadata_service.write_metadata(image_path, metadata, targets=targets_to_use)` around line 2535.
- No payload size guard is applied before handing control to `MetadataService`. Large metadata structures are written verbatim, so the new fallback should hook in before this call.
## Additional format helper (`_save_additional_format`)
- JPEG copies created via the "additional format" option write metadata in two places:
- A direct `pil_image.save(... format='JPEG' ...)` call that omits size monitoring.
- A subsequent `self.metadata_service.write_metadata(additional_path, metadata, targets=targets)` call when `additional_format.lower() not in ['svg']`.
- Similar to the primary path, there is no guardrail around metadata size prior to embedding.
## Advanced alpha save (`_save_with_advanced_alpha`)
- When the main run requests JPEG output with alpha handling, the function eventually saves the composited RGB image via `processed_image.save(image_path, format=format, **save_options)` (with `format` resolved to `'JPEG'`). The same `write_metadata` invocation in the parent method handles metadata afterwards, still without a byte-limit check.
## Action Items
1. Introduce a pre-embed inspector that estimates the combined XMP/IPTC payload size and decides which fallback tier to use before calling `write_metadata`.
2. Plumb the chosen fallback stage back into the provenance block (e.g. `provenance.jpeg_fallback_stage`) so downstream tooling can report what happened.
3. Ensure the additional-format path reuses the same guard logic to avoid silent divergence between primary and secondary JPEGs.