From 31edd35463b0575f35d047c69473e701abf75931 Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Mon, 26 Sep 2022 17:00:39 +0200 Subject: [PATCH] Print image overviews --- Sources/Generator/Content/ThumbnailStyle.swift | 4 ++-- Sources/Generator/Files/ImageGenerator.swift | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Sources/Generator/Content/ThumbnailStyle.swift b/Sources/Generator/Content/ThumbnailStyle.swift index f920460..2f439a7 100644 --- a/Sources/Generator/Content/ThumbnailStyle.swift +++ b/Sources/Generator/Content/ThumbnailStyle.swift @@ -23,9 +23,9 @@ enum ThumbnailStyle: String, CaseIterable { case .large: return 374 case .square: - return height + return 178 case .small: - return height + return 78 } } } diff --git a/Sources/Generator/Files/ImageGenerator.swift b/Sources/Generator/Files/ImageGenerator.swift index 5a97aed..5dde4b6 100644 --- a/Sources/Generator/Files/ImageGenerator.swift +++ b/Sources/Generator/Files/ImageGenerator.swift @@ -113,6 +113,7 @@ final class ImageGenerator { } func requireImage(at destination: String, generatedFrom source: String, requiredBy path: String, width: Int, height: Int?) -> NSSize { + requiredImages.insert(destination) let height = height.unwrapped(CGFloat.init) let sourceUrl = input.appendingPathComponent(source) guard sourceUrl.exists else { @@ -158,6 +159,8 @@ final class ImageGenerator { } printMissingImages() printImageWarnings() + printGeneratedImages() + printTotalImageCount() } private func printMissingImages() { @@ -180,6 +183,20 @@ final class ImageGenerator { } } + private func printGeneratedImages() { + guard !generatedImages.isEmpty else { + return + } + print("\(generatedImages.count) images generated:") + for image in generatedImages { + print(" " + image) + } + } + + private func printTotalImageCount() { + print("\(requiredImages.count) images") + } + private func addWarning(_ message: String, destination: String, path: String) { let warning = " \(destination): \(message) required by \(path)" imageWarnings.insert(warning) @@ -269,5 +286,6 @@ final class ImageGenerator { addWarning("Failed to write image (\(error))", job: job) return } + generatedImages.insert(job.destination) } }