This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# File extensions that should use XMP sidecars
|
||||
SIDECAR_EXTENSIONS = {".dng", ".nef", ".cr2", ".cr3", ".arw", ".raf", ".orf", ".rw2"}
|
||||
|
||||
|
||||
type Caption = str | None
|
||||
type Keywords = list[str] | None
|
||||
type Color = str | None
|
||||
|
||||
|
||||
class MetadataWriter:
|
||||
"""
|
||||
Write metadata (captions and keywords) to image files.
|
||||
For DNG files, creates/updates XMP sidecar files.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, force_sidecar: bool = False, append: bool = True, prefix: str = "photools"
|
||||
):
|
||||
self.force_sidecar = force_sidecar
|
||||
self.append = append
|
||||
self.prefix = prefix
|
||||
|
||||
def write_caption(self, path: Path, caption: Caption): ...
|
||||
|
||||
def write_keywords(self, path: Path, keywords: Keywords): ...
|
||||
|
||||
def write_color(self, path: Path, color: Color): ...
|
||||
|
||||
def write(
|
||||
self,
|
||||
path: Path,
|
||||
caption: Caption = None,
|
||||
keywords: Keywords = None,
|
||||
color: Color = None,
|
||||
):
|
||||
if caption is not None:
|
||||
self.write_caption(path, caption)
|
||||
if keywords is not None:
|
||||
self.write_keywords(path, keywords)
|
||||
if color is not None:
|
||||
self.write_color(path, color)
|
||||
Reference in New Issue
Block a user