Giter Site home page Giter Site logo

Comments (4)

aashishdhawan avatar aashishdhawan commented on August 20, 2024 1

@slashburn Thank you for your feedback and valuable suggestion, we'll look into this in future release.
Meanwhile if you managed to solve this for yourself, feel free to submit a pull request.

from imagepicker.

slashburn avatar slashburn commented on August 20, 2024

I did a workaround with a UIImage extension, but I agree it would be better to include it in the project directly:

class func cropCameraImage(image: UIImage, viewHeight: CGFloat) -> UIImage {

        //The height of the bottom view in the ImagePickerCamera
        //It is specified as 101 points.  
        let imagePickerBottomContainerHeight: CGFloat = 101.0
        let contextImage = UIImage(CGImage: image.CGImage!)


        let percentage = imagePickerBottomContainerHeight / viewHeight
        let newHeight = image.size.height - percentage*image.size.height
        let cropRect = CGRect(x: 0, y: 0, width: image.size.width, height: newHeight)
        let imageRef: CGImageRef = CGImageCreateWithImageInRect(contextImage.CGImage, cropRect)!
        let croppedImage = UIImage(CGImage: imageRef, scale: image.scale, orientation: image.imageOrientation)

        return croppedImage
    }

The first parameter is the UIImage that is returned from the camera, the second is the height of the entire screen. So you would call it like in your view controller (that conforms to the ImagePickerDelegate) like so:

let croppedImage = UIImage.cropCameraImage(image, self.view.frame.height)

from imagepicker.

choutiy avatar choutiy commented on August 20, 2024

did anyone figure out how to achieve this one?

from imagepicker.

onmyway133 avatar onmyway133 commented on August 20, 2024

@slashburn @choutiy Hi, this is a valid concern. While some people find it confused not to crop the lower part, other people actually want to take image full screen. This was by design so we don't plan to change it, in the mean time @choutiy you can take a look at what @slashburn suggested

from imagepicker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.