from __future__ import annotations from pathlib import Path from tools.exiftool import run_exiftool_command EXCLUDED_COPY_TAGS = [ "--File:all", "--ExifTool:all", "--Composite:all", "--SourceFile", "--Directory", "--FileName", "--FileSize", "--FileModifyDate", "--FileAccessDate", "--FileInodeChangeDate", "--FilePermissions", "--FileType", "--FileTypeExtension", "--MIMEType", "--ImageWidth", "--ImageHeight", "--ExifImageWidth", "--ExifImageHeight", "--PixelXDimension", "--PixelYDimension", "--RelatedImageWidth", "--RelatedImageHeight", "--ImageSize", "--Megapixels", "--XResolution", "--YResolution", "--ResolutionUnit", "--Duration", "--DurationScale", "--DurationValue", "--MediaDuration", "--MediaTimeScale", "--TrackDuration", "--TrackCreateDate", "--TrackModifyDate", "--MediaCreateDate", "--MediaModifyDate", "--AvgBitrate", "--Bitrate", "--MaxBitrate", "--VideoFrameRate", "--CaptureFrameRate", "--AudioBitrate", "--AudioSampleRate", "--AudioSamplingRate", "--AudioBitsPerSample", "--AudioChannels", "--CompressorID", "--CompressorName", "--MediaDataOffset", "--MediaDataSize", ] def copy_meaningful_metadata( exiftool: str, source: Path, destination: Path, *, extra_excluded_tags: list[str] | None = None, ) -> None: copy_meaningful_metadata_with_exiftool( exiftool, source, destination, extra_excluded_tags=extra_excluded_tags, ) def copy_meaningful_metadata_with_exiftool( exiftool: str, source: Path, destination: Path, *, extra_excluded_tags: list[str] | None = None, ) -> None: args = [ "-overwrite_original", "-TagsFromFile", str(source), "-all:all", *EXCLUDED_COPY_TAGS, *(extra_excluded_tags or []), str(destination), ] run_exiftool_command( exiftool, args, check=True, capture_output=True, text=True, )