diff --git a/Sources/Pulse/Helpers/ImageProcessor.swift b/Sources/Pulse/Helpers/ImageProcessor.swift index 6b719eeb8..1e7c94659 100644 --- a/Sources/Pulse/Helpers/ImageProcessor.swift +++ b/Sources/Pulse/Helpers/ImageProcessor.swift @@ -19,8 +19,14 @@ import ImageIO #endif enum Graphics { - static func resize(_ image: UIImage, to size: CGSize) -> PlatformImage? { -#if os(macOS) + static func resize(_ image: PlatformImage, to size: CGSize) -> PlatformImage? { +#if canImport(UIKit) + UIGraphicsBeginImageContextWithOptions(size, false, 1.0) + image.draw(in: CGRect(x: 0, y: 0, width: size.width, height: size.height)) + let thumbnail = UIGraphicsGetImageFromCurrentImageContext() + UIGraphicsEndImageContext() + return thumbnail +#elseif canImport(AppKit) let newImage = NSImage(size: newSize) newImage.lockFocus() let sourceRect = NSMakeRect(0, 0, size.width, size.height) @@ -29,11 +35,7 @@ enum Graphics { newImage.unlockFocus() return newImage #else - UIGraphicsBeginImageContextWithOptions(size, false, 1.0) - image.draw(in: CGRect(x: 0, y: 0, width: size.width, height: size.height)) - let thumbnail = UIGraphicsGetImageFromCurrentImageContext() - UIGraphicsEndImageContext() - return thumbnail + return image #endif }