From 7ca8af3bdc27992d0b0474912437539b91cf68bb Mon Sep 17 00:00:00 2001 From: fmodf Date: Tue, 16 Jul 2024 17:13:16 +0200 Subject: [PATCH] wip --- .../AppCore/Files/FileProcessing.swift | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ConversationsClassic/AppCore/Files/FileProcessing.swift b/ConversationsClassic/AppCore/Files/FileProcessing.swift index 226ac60..582682f 100644 --- a/ConversationsClassic/AppCore/Files/FileProcessing.swift +++ b/ConversationsClassic/AppCore/Files/FileProcessing.swift @@ -28,14 +28,24 @@ final class FileProcessing { // create thumbnail if not exists switch localName.attachmentType { case .image: - guard let image = UIImage(contentsOfFile: localUrl.path) else { return nil } + guard let image = UIImage(contentsOfFile: localUrl.path) else { + print("FileProcessing: Error loading image: \(localUrl)") + return nil + } let targetSize = CGSize(width: Const.attachmentPreviewSize, height: Const.attachmentPreviewSize) - guard let thumbnail = scaleAndCropImage(image, targetSize) else { return nil } - guard let data = thumbnail.pngData() else { return nil } + guard let thumbnail = scaleAndCropImage(image, targetSize) else { + print("FileProcessing: Error scaling image: \(localUrl)") + return nil + } + guard let data = thumbnail.pngData() else { + print("FileProcessing: Error converting thumbnail of \(localUrl) to data") + return nil + } do { try data.write(to: thumbnailUrl) return thumbnailFileName } catch { + print("FileProcessing: Error writing thumbnail: \(error)") return nil }