ruslanskorb / RSKImageCropper

An image cropper / photo cropper for iOS like in the Contacts app with support for landscape orientation.
MIT License
2.45k stars 471 forks source link

when I crop my picture from front camera, I zoomed photo and crop the bottom half of the photo, but I got result with top half of the photo #209

Closed miaotaoii closed 5 years ago

miaotaoii commented 5 years ago

前置相机拍照后剪裁时,剪裁出的结果上下时反的

miaotaoii commented 5 years ago

前置相机拍照后剪裁时,剪裁出的结果上下是反的

ruslanskorb commented 5 years ago

@miaotaoii Please, use English. Also, could you provide an example of what you expect and what you have?

uestchang commented 5 years ago

I think u can check the exif info with the image , if the orientation/rotation of image is wrong , fix it by your own func.

miaotaoii commented 5 years ago

I just crop photo use RSKImageCropViewController.cropImage(), and then get the result in func imageCropViewController(_ controller: RSKImageCropViewController, didCropImage croppedImage: UIImage, usingCropRect cropRect: CGRect) { ... }. without changing orientation or rotation

And I got the correct result image when I use rear camera to take photo and crop it, but when I crop my photo from front camera, the result image is upside down ,which I means, I cropped the bottom half of the photo, but I got result with top half of the photo,

here is my code :

in CropImageViewController:RSKImageCropViewController,RSKImageCropViewControllerDelegate:

  @objc func cropBtnClicked(){
        super.cropImage()
    }

  func imageCropViewController(_ controller: RSKImageCropViewController, didCropImage        croppedImage: UIImage, usingCropRect cropRect: CGRect) {
        let photoVc = PreViewPhotoViewController(image: croppedImage, imageRect : cropRect )
        photoVc.hidesBottomBarWhenPushed = true
        self.navigationController?.pushViewController(photoVc, animated: true)
     }

in PreViewPhotoViewController(I just show the photo):

  func prepareImage(){
        let scale : CGFloat = 0.16
        let yy = ScreenUtils.getHeight() * scale
        MLog.log(tag: TAG, logStr : "y : \(yy) backgroundImage.size.height  \(backgroundImage.size.height) ")
         let photoView = UIImageView()
        photoView.contentMode = .scaleAspectFill
        photoView.image = backgroundImage
        photoView.frame = CGRect(x: 0, y: yy, width: ScreenUtils.getWidth(), height: 300)
        view.addSubview(photoView)
    }

can u help me with this problem ? @ruslanskorb @uestchang

ruslanskorb commented 5 years ago

@miaotaoii Check the image you are using to initialize RSKImageCropViewController. Does it have the correct orientation? Check the image you are getting in didCropImage:... method of RSKImageCropViewControllerDelegate. Does it have the correct orientation? Also, could you provide a sample project that reproduces your problem?

miaotaoii commented 5 years ago

thanks ,maybe not crop problem I think, I will find out it later