IGRSoft / IGRPhotoTweaks

Drag, Rotate, Scale and Crop
https://igrsoft.com
MIT License
237 stars 72 forks source link

Change image quality by setting image on IGRPhotoTweakViewController #42

Open NijoshNewAge opened 5 years ago

NijoshNewAge commented 5 years ago

After choosing an image from UIImagePicker, which will be passed to the IGRPhotoTweakViewController. The image will be shown in there but it loses its original quality. Does anyone have the answer?

ikorich commented 5 years ago

uses original size let image = info[UIImagePickerController.InfoKey.originalImage] as! UIImage

@NijoshNewAge can you provide more info?

NijoshNewAge commented 5 years ago
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

        let mediaType = info[UIImagePickerControllerMediaType] as! NSString

        if mediaType.isEqual(to: kUTTypeImage as String) {

            var imagePicked: UIImage?

            if isEditing {

                imagePicked = info[UIImagePickerControllerEditedImage] as? UIImage

            } else {

                imagePicked = info[UIImagePickerControllerOriginalImage] as? UIImage

            }

            picker.dismiss(animated: false) {

                let imageCropViewController = UIStoryboard(name: “Main", bundle: nil).instantiateViewController(withIdentifier: "ImageCropperViewController") as! ImageCropperViewController

                imageCropViewController.image = imagePicked              

                imageCropViewController.delegate = self

                self.viewController.present(imageCropViewController, animated: true, completion: nil)

            }

        } else if mediaType.isEqual(to: kUTTypeMovie as String) {

            let videoURL = info[UIImagePickerControllerMediaURL] as! NSURL

            let thumbImage = self.createThumbImage(videoUrl: videoURL)

            delegate.finishedPickingVideo!(videoUrl: videoURL, thumbImage: thumbImage)

            self.viewController.dismiss(animated: true)

        }
    }

This was my code in that delegate. But I didn't find where that image loose its quality?.

ikorich commented 5 years ago

please check which one info[] calls?