wip
This commit is contained in:
parent
6974ac5b7d
commit
7ca8af3bdc
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue