PM-Oberfläche: Favoriten/Navigator/Aufgaben, Tabs, PM-Filter, PM-Kacheln, IPTC-Layout wie PM, ⌘I Mass-Edit, ⌘U Upload, Code-Ersetzung live, 8 Farbklassen, paralleles + gecachtes Metadaten-Laden, BILDER/INPUT+SENT
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012bGzgsxrmbBhDzeMV2L57D
This commit is contained in:
1 parent
d100249c12
commit
c0ee93995f
18 files changed
+1311
-515
No files matched your search
@@ -119,9 +119,9 @@ public final class ExifTool: @unchecked Sendable {
|
||||
/// Keys for IPTC/XMP keep their group ("IPTC:Keywords"), EXIF keys are plain ("Model").
|
||||
public func readMetadata(files: [URL]) async throws -> [String: [String: MetadataValue]] {
|
||||
guard !files.isEmpty else { return [:] }
|
||||
var args = ["-json", "-G1", "-fast", "-a",
|
||||
var args = ["-json", "-G1", "-fast2", "-a",
|
||||
"-XMP-xmp:Rating#", "-XMP-xmp:Label", "-XMP-photomech:Tagged#", "-XMP-photomech:ColorClass#",
|
||||
"-Make", "-Model", "-LensModel", "-LensID", "-SerialNumber", "-ISO", "-ExposureTime", "-FNumber",
|
||||
"-Make", "-Model", "-LensModel", "-Lens", "-SerialNumber", "-ISO", "-ExposureTime", "-FNumber",
|
||||
"-FocalLength", "-DateTimeOriginal", "-CreateDate", "-SubSecTimeOriginal", "-OffsetTimeOriginal", "-ImageWidth", "-ImageHeight",
|
||||
"-Orientation#", "-Artist", "-GPSLatitude#", "-GPSLongitude#"]
|
||||
for f in IPTCField.all {
|
||||
@@ -152,7 +152,7 @@ public final class ExifTool: @unchecked Sendable {
|
||||
}
|
||||
|
||||
/// JSON values coming back from exiftool.
|
||||
public enum MetadataValue: Sendable, Hashable {
|
||||
public enum MetadataValue: Sendable, Hashable, Codable {
|
||||
case string(String)
|
||||
case number(Double)
|
||||
case bool(Bool)
|
||||
@@ -202,3 +202,36 @@ public enum MetadataValue: Sendable, Hashable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Several exiftool processes in parallel – reading 2000+ files is I/O + Perl bound, so this scales well on Apple Silicon.
|
||||
public final class ExifToolPool: @unchecked Sendable {
|
||||
public let workers: [ExifTool]
|
||||
|
||||
public init(executable: URL, count: Int = min(6, max(2, ProcessInfo.processInfo.activeProcessorCount / 2))) {
|
||||
workers = (0..<count).map { _ in ExifTool(executable: executable) }
|
||||
}
|
||||
|
||||
public var primary: ExifTool { workers[0] }
|
||||
|
||||
public func shutdown() { workers.forEach { $0.shutdown() } }
|
||||
|
||||
/// Reads file groups (RAW + its sidecar stay together) in chunks spread over all workers;
|
||||
/// `onChunk` is called as results arrive.
|
||||
public func readMetadata(groups: [[URL]], groupsPerChunk: Int = 50,
|
||||
onChunk: @escaping @Sendable ([String: [String: MetadataValue]]) async -> Void) async {
|
||||
let chunks: [[URL]] = stride(from: 0, to: groups.count, by: groupsPerChunk).map {
|
||||
groups[$0..<min($0 + groupsPerChunk, groups.count)].flatMap { $0 }
|
||||
}
|
||||
await withTaskGroup(of: Void.self) { group in
|
||||
for w in 0..<workers.count {
|
||||
let worker = workers[w]
|
||||
let mine = chunks.enumerated().filter { $0.offset % workers.count == w }.map(\.element)
|
||||
group.addTask {
|
||||
for chunk in mine {
|
||||
if let meta = try? await worker.readMetadata(files: chunk) { await onChunk(meta) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user