From e64f5dfac1917e4107f8fcfa2269b6661075f774 Mon Sep 17 00:00:00 2001 From: Eric Li Date: Mon, 12 Sep 2016 22:41:42 -0400 Subject: [PATCH] save image only if picker was camera --- Omarview/ViewController.swift | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/Omarview/ViewController.swift b/Omarview/ViewController.swift index 3b0e3bf..879a17d 100644 --- a/Omarview/ViewController.swift +++ b/Omarview/ViewController.swift @@ -124,8 +124,10 @@ class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavig Any]) { if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage { - // Save to library - UIImageWriteToSavedPhotosAlbum(pickedImage, nil, nil, nil) + // Save to library if camera + if (picker.sourceType == .camera) { + UIImageWriteToSavedPhotosAlbum(pickedImage, nil, nil, nil) + } // CloudVision call let vision = CloudVision(callbackObject: self) @@ -143,18 +145,6 @@ class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavig } - func scaleImage(_ image: UIImage, scale: CGFloat) -> UIImage? { - let original = image.size - let newSize = CGSize(width: original.width * scale, height: original.height * scale) - - UIGraphicsBeginImageContext(newSize) - image.draw(in: CGRect(x: 0, y: 0, width: newSize.width, height: newSize.height)) - let compressedImage = UIGraphicsGetImageFromCurrentImageContext() - UIGraphicsEndImageContext() - - return compressedImage - } - func eventEditViewController(_ controller: EKEventEditViewController, didCompleteWith action: EKEventEditViewAction){ self.dismiss(animated: true, completion: nil) } @@ -189,7 +179,7 @@ class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavig func connectionError() { LoadingIndicatorView.hide() - let alert = UIAlertController(title: "Error", message:"We were unable to connect to the internet. Try again.", preferredStyle: .alert) + let alert = UIAlertController(title: "Error", message:"Please try again.", preferredStyle: .alert) let OKAction = UIAlertAction(title: "OK", style: .default) { (action) in }