Skip to content

Commit

Permalink
save image only if picker was camera
Browse files Browse the repository at this point in the history
  • Loading branch information
eli8527 committed Sep 13, 2016
1 parent 6644541 commit e64f5df
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions Omarview/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit e64f5df

Please sign in to comment.