wip
This commit is contained in:
parent
6974ac5b7d
commit
7ca8af3bdc
|
@ -28,14 +28,24 @@ final class FileProcessing {
|
||||||
// create thumbnail if not exists
|
// create thumbnail if not exists
|
||||||
switch localName.attachmentType {
|
switch localName.attachmentType {
|
||||||
case .image:
|
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)
|
let targetSize = CGSize(width: Const.attachmentPreviewSize, height: Const.attachmentPreviewSize)
|
||||||
guard let thumbnail = scaleAndCropImage(image, targetSize) else { return nil }
|
guard let thumbnail = scaleAndCropImage(image, targetSize) else {
|
||||||
guard let data = thumbnail.pngData() else { return nil }
|
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 {
|
do {
|
||||||
try data.write(to: thumbnailUrl)
|
try data.write(to: thumbnailUrl)
|
||||||
return thumbnailFileName
|
return thumbnailFileName
|
||||||
} catch {
|
} catch {
|
||||||
|
print("FileProcessing: Error writing thumbnail: \(error)")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue