Skip to content

Add metadata and capture roll/frame to export filename templates, with safe frame padding and pre-export settings flush - #721

Merged
marcinz606 merged 5 commits into
marcinz606:mainfrom
jboneng:feat/metadata_fields_as_accessable_file_name_template_variables
Aug 1, 2026
Merged

Add metadata and capture roll/frame to export filename templates, with safe frame padding and pre-export settings flush#721
marcinz606 merged 5 commits into
marcinz606:mainfrom
jboneng:feat/metadata_fields_as_accessable_file_name_template_variables

Conversation

@jboneng

@jboneng jboneng commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Export filename templates can now include analog metadata and Scanlight capture identity (roll, frame, camera, film, etc.). Capture roll/frame are stamped automatically on import and editable in the Metadata panel. A pre-export flush ensures the export always uses the latest sidebar settings, even when the user clicks Export before the 500ms debounce has fired.

New filename template variables

All metadata variables are read from the file’s MetadataConfig at export time (the Metadata panel for the current frame, or each file’s saved config in a batch). Path-unsafe characters are stripped; empty fields render as empty strings.

Variable Source Notes
{{ roll }} MetadataConfig.capture_roll Scanlight capture roll name. Stamped on capture import; editable in Metadata → Scanning → Roll / Frame. Fallback: parsed from a {roll}_Frame{NNN} source filename stem. Not the Roll Analysis normalization name (process.roll_name).
{{ frame }} MetadataConfig.capture_frame Capture frame number (integer). Stamped on capture import; editable in Metadata → Roll / Frame. Fallback: parsed from the same {roll}_Frame{NNN} stem. Unset (none) if unknown.
{{ frame_padded }} Derived from frame Zero-padded frame (012). Empty when frame is unset. Same as {{ frame|pad(3) }}.
{{ frame|pad(N) }} Derived from frame Jinja pad filter — zero-pads to N digits; empty when frame is unset (avoids "%03d" % frame crashing the whole template).
{{ camera }} camera_make + camera_model Combined as "Make Model", trimmed.
{{ camera_make }} MetadataConfig.camera_make From gear library or manual Metadata entry.
{{ camera_model }} MetadataConfig.camera_model From gear library or manual Metadata entry.
{{ lens }} lens_model or lens_make Model if set, otherwise make.
{{ lens_make }} MetadataConfig.lens_make From gear library or manual entry.
{{ lens_model }} MetadataConfig.lens_model From gear library or manual entry.
{{ focal_length }} MetadataConfig.focal_length_mm Lens focal length in mm.
{{ film }} MetadataConfig.film Film stock name.
{{ film_iso }} MetadataConfig.film_iso Film ISO.
{{ film_manufacturer }} MetadataConfig.film_manufacturer Film manufacturer.
{{ film_color_type }} MetadataConfig.film_color_type e.g. Color negative.
{{ film_format }} MetadataConfig.format / format_other Film format (35mm, 120, …). Uses format_other when format is "Other". Distinct from export {{ format }} (JPEG/TIFF).
{{ developer }} MetadataConfig.developer Developer.
{{ push_pull }} MetadataConfig.push_pull Integer −3…+3 (0 = Normal).
{{ scanning }} MetadataConfig.scanning Scanning method note.
{{ exposure }} MetadataConfig.exposure_override Free-text exposure note.

Existing export variables (original_name, colorspace, format, paper_ratio, size, dpi, target_px, border, date) are unchanged.

Example

{% if roll %}{{ roll }}{% endif %}{% if frame %}Frame{{ frame|pad(3) }}{% endif %}{{ film }}{{ film_iso }}{{ camera }}_{{ original_name }}

Use {% if %} blocks when a variable may be empty — otherwise literal labels like Frame can remain in the filename even when roll/frame are unset.

Pre-export settings flush

The Export sidebar debounces changes to Format / Size / Colour / Destination for 500ms before writing them into WorkspaceConfig. Without a flush, clicking Export (or Export Presets) immediately after editing the filename pattern or destination could run against stale config.

This PR adds _flush_export_settings() on the export sidebar, registered on the controller as flush_export_settings. Before any export path runs, the controller calls _flush_export_ui(), which stops the debounce timer and persists the form immediately. Covered entry points:

  • Export current frame / selected / batch (chevron menu)
  • Export Presets
  • Contact sheet

Other changes

  • Metadata panel: Roll / Frame fields under Scanning (backed by capture_roll / capture_frame).
  • Capture import: Scanlight roll_name and frame_number are stamped into metadata when a captured file is opened.
  • Template failures: Jinja render errors are logged before falling back to original_name.
  • Docs: docs/TEMPLATING.md and docs/USER_GUIDE.md updated.

Test plan

  • Fill Metadata (camera, film, ISO) and export with a template containing those variables — filename reflects the values.
  • Capture a frame via Scanlight — roll/frame appear in Metadata and in export filenames.
  • Export a non-capture file with {{ frame|pad(3) }} in the pattern — template does not fall back to original_name.
  • Change the filename pattern or destination, click Export within 500ms — export uses the new settings.
  • Export Presets with a metadata template — each preset uses its own filename pattern and destination.
    Fixes expand export filename templates with metadata variables #704

@jboneng
jboneng marked this pull request as draft August 1, 2026 14:40
@jboneng
jboneng marked this pull request as ready for review August 1, 2026 15:06
@marcinz606
marcinz606 merged commit 92d6913 into marcinz606:main Aug 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

expand export filename templates with metadata variables

2 participants