Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions negpy/desktop/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3362,12 +3362,10 @@ def request_linear_output_export(self, files: list[dict] | None = None) -> None:
return

exported = 0
cfg = self.state.config
geometry = cfg.geometry
expansion = self.state.linear_expansion
rgbscan = cfg.rgbscan
stitch = cfg.stitch if cfg.stitch.stitch_enabled else None
for f in supported:
params = self._batch_params_for(f)
stitch = params.stitch if params.stitch.stitch_enabled else None
stem = os.path.splitext(os.path.basename(f["path"]))[0]
out_path = os.path.join(export_path, f"{stem}_linear.tiff")
counter = 2
Expand All @@ -3378,12 +3376,12 @@ def request_linear_output_export(self, files: list[dict] | None = None) -> None:
export_linear_output(
f["path"],
out_path,
geometry=geometry,
geometry=params.geometry,
expansion=expansion,
rgbscan=rgbscan,
rgbscan=params.rgbscan,
stitch=stitch,
flatfield=cfg.flatfield,
process=cfg.process,
flatfield=params.flatfield,
process=params.process,
apply_wb=self.state.linear_apply_wb,
apply_flatfield=self.state.linear_apply_flatfield,
apply_sensor=self.state.linear_apply_sensor,
Expand Down
25 changes: 17 additions & 8 deletions negpy/services/export/linear_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,21 @@ def _normalize_wb_rgb(wb: tuple[float, float, float, float]) -> tuple[float, flo
return (wb[0] / g, 1.0, wb[2] / g)


def _build_xmp(source_path: str, wb: _CameraWB) -> bytes:
r, g, b = _normalize_wb_rgb(wb.as_shot)
def _build_xmp(source_path: str, wb: _CameraWB, title: str = "", wb_applied: bool = False) -> bytes:
raw_name = os.path.basename(source_path)
title_block = ""
if title:
title_block = f" <dc:title>\n <rdf:Alt>\n <rdf:li xml:lang='x-default'>{title}</rdf:li>\n </rdf:Alt>\n </dc:title>\n"
desc_block = ""
if not wb_applied:
r, g, b = _normalize_wb_rgb(wb.as_shot)
desc_block = (
" <dc:description>\n"
" <rdf:Alt>\n"
f" <rdf:li xml:lang='x-default'>RAW-WB: {r:.6f} {g:.6f} {b:.6f}</rdf:li>\n"
" </rdf:Alt>\n"
" </dc:description>\n"
)
xmp = (
"<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>\n"
"<x:xmpmeta xmlns:x='adobe:ns:meta/'>\n"
Expand All @@ -464,11 +476,8 @@ def _build_xmp(source_path: str, wb: _CameraWB) -> bytes:
" </rdf:Description>\n"
" <rdf:Description rdf:about=''\n"
" xmlns:dc='http://purl.org/dc/elements/1.1/'>\n"
" <dc:description>\n"
" <rdf:Alt>\n"
f" <rdf:li xml:lang='x-default'>RAW-WB: {r:.6f} {g:.6f} {b:.6f}</rdf:li>\n"
" </rdf:Alt>\n"
" </dc:description>\n"
f"{title_block}"
f"{desc_block}"
" </rdf:Description>\n"
"</rdf:RDF>\n"
"</x:xmpmeta>\n"
Expand Down Expand Up @@ -546,7 +555,7 @@ def _write_tiff(

extratags: list[tuple] = []
if camera_wb is not None and source_path is not None:
xmp_bytes = _build_xmp(source_path, camera_wb)
xmp_bytes = _build_xmp(source_path, camera_wb, title=description, wb_applied=wb_applied)
extratags.append((700, 1, len(xmp_bytes), xmp_bytes, True))

if source_meta is not None:
Expand Down
Loading