From c727bdf91eca341ac1cad306d76098cad1a7d7ab Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Fri, 16 Sep 2022 15:32:55 +0200 Subject: [PATCH] Scale images to integer heights --- Sources/Generator/Extensions/NSSize+Extensions.swift | 2 +- Sources/Generator/Files/FileSystem.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Generator/Extensions/NSSize+Extensions.swift b/Sources/Generator/Extensions/NSSize+Extensions.swift index 603b8fd..9018311 100644 --- a/Sources/Generator/Extensions/NSSize+Extensions.swift +++ b/Sources/Generator/Extensions/NSSize+Extensions.swift @@ -12,7 +12,7 @@ extension NSSize { return self } - let height = height * desiredWidth / width + let height = (height * desiredWidth / width).rounded(.down) return NSSize(width: desiredWidth, height: height) } } diff --git a/Sources/Generator/Files/FileSystem.swift b/Sources/Generator/Files/FileSystem.swift index 839c702..ca1ec0b 100644 --- a/Sources/Generator/Files/FileSystem.swift +++ b/Sources/Generator/Files/FileSystem.swift @@ -316,7 +316,7 @@ final class FileSystem { let scaledImage = sourceImage.scaledDown(to: destinationSize) let scaledSize = scaledImage.size - if abs(scaledImage.size.width - desiredWidth) > 2 { + if abs(scaledSize.width - desiredWidth) > 2 { log.add(warning: "Desired width \(desiredWidth), got \(scaledSize.width)", source: destination) } if abs(destinationSize.height - scaledImage.size.height) > 2 {