From f2b4851599130d756e57d2c027c9d4af0fc9f5cc Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Sun, 28 Aug 2022 14:02:13 +0200 Subject: [PATCH] Create 2x images explicitly --- WebsiteGenerator/Files/FileSystem.swift | 2 +- .../Generators/ThumbnailListGenerator.swift | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/WebsiteGenerator/Files/FileSystem.swift b/WebsiteGenerator/Files/FileSystem.swift index 42c4b2a..e4cddb5 100644 --- a/WebsiteGenerator/Files/FileSystem.swift +++ b/WebsiteGenerator/Files/FileSystem.swift @@ -187,7 +187,7 @@ final class FileSystem { } @discardableResult - func requireImage(source: String, destination: String, width: Int, desiredHeight: Int? = nil, createDoubleVersion: Bool = false) -> NSSize { + func requireImage(source: String, destination: String, width: Int, desiredHeight: Int? = nil) -> NSSize { let height = desiredHeight.unwrapped(CGFloat.init) let sourceUrl = input.appendingPathComponent(source) let image = ImageOutput(source: source, width: width, desiredHeight: desiredHeight) diff --git a/WebsiteGenerator/Generators/ThumbnailListGenerator.swift b/WebsiteGenerator/Generators/ThumbnailListGenerator.swift index 757f3f6..f939bb7 100644 --- a/WebsiteGenerator/Generators/ThumbnailListGenerator.swift +++ b/WebsiteGenerator/Generators/ThumbnailListGenerator.swift @@ -41,8 +41,15 @@ struct ThumbnailListGenerator { source: fullThumbnailPath, destination: fullThumbnailPath, width: style.width, - desiredHeight: style.height, - createDoubleVersion: true) + desiredHeight: style.height) + + // Create image version for high-resolution screens + files.requireImage( + source: fullThumbnailPath, + destination: fullThumbnailPath.insert("@2x", beforeLast: "."), + width: style.width * 2, + desiredHeight: style.height * 2) + return factory.thumbnail(style: style).generate(content, shouldIndent: false) } }