소스 검색

Improved code

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 년 전
부모
커밋
e286660b88
1개의 변경된 파일9개의 추가작업 그리고 6개의 파일을 삭제
  1. 9 6
      iOSClient/Main/Create cloud/NCUploadScanDocument.swift

+ 9 - 6
iOSClient/Main/Create cloud/NCUploadScanDocument.swift

@@ -160,23 +160,23 @@ class NCUploadScanDocument: ObservableObject {
         case 0:
             baseHeight *= 1
             baseWidth *= 1
-            compressionQuality = 0.3
+            compressionQuality = 0.1
         case 1:
             baseHeight *= 2
             baseWidth *= 2
-            compressionQuality = 0.6
+            compressionQuality = 0.2
         case 2:
             baseHeight *= 4
             baseWidth *= 4
-            compressionQuality = 0.8
+            compressionQuality = 0.4
         case 3:
             baseHeight *= 6
             baseWidth *= 6
-            compressionQuality = 0.9
+            compressionQuality = 0.6
         case 4:
             baseHeight *= 8
             baseWidth *= 8
-            compressionQuality = 1
+            compressionQuality = 0.8
         default:
             break
         }
@@ -207,7 +207,10 @@ class NCUploadScanDocument: ObservableObject {
         let img = UIGraphicsGetImageFromCurrentImageContext()
         let imageData = img?.jpegData(compressionQuality: CGFloat(compressionQuality))
         UIGraphicsEndImageContext()
-        return UIImage(data: imageData!) ?? image
+        if let imageData = imageData, let image = UIImage(data: imageData) {
+            return image
+        }
+        return image
     }
 }