Giter Club home page Giter Club logo

babcropperview's Introduction

BABCropperView

A customizable image cropper view based on UIScrollView.

Sample Project

Supports iOS 8.0+

  • Crop size is fully configurable
  • Allows cropping of any part of the image
  • Fully customizable with sensible defaults
  • Works easily with or without Auto Layout
  • Uses memory efficient image crop which handles multiple image orientations

This is a UIView subclass which allows a user to crop an image to a desired size.

Sample Code & Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • Requires iOS 8.0+

Installation

BABCropperView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "BABCropperView"

Author

Bryn Bodayle, [email protected]

License

BABFrameObservingInputAccessoryView is available under the MIT license. See the LICENSE file for more info.

babcropperview's People

Contributors

brynbodayle avatar dionc avatar ehlersd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

babcropperview's Issues

Wrong bounds on iPhone Plus

First of all, thanks for great library!

I found one issue with big screen iPhones.

img_4310

Can be fixed with replacement of this line:

self.borderView.layer.cornerRadius = CGRectGetWidth(self.borderView.bounds)/2.0f;

to

self.borderView.layer.cornerRadius = CGRectGetWidth(displayCropRect)/2.0f;

How to centre the image on load & scale to take up full screen

Two Questions:

  1. When image is loaded and if the image size is larger then the crop view size, I want to centre the image (currently the image scroll view is not auto scrolled to centre).

  2. When image is loaded, I want the image scale to take up the entire phone Window (user can zoom in later if they want).

For question 2 I've tried to set "cropDisplayScale", "contentScaleFactor" & "scrollView.setZoomScale" but seems no luck.

discrepancy in - (void)updateScrollViewZoomScales

In updateScrollViewZoomScales method:

else { //landscape image

if((scrollViewHeight >= scrollViewWidth) || (self.cropSize.width/self.cropSize.height < imageViewWidth/imageViewHeight)) {
.....
}

The OR operator is used in else condition instead of AND as defined in if condition.

allow to restrict max zoom level

ATM max zoom is set to 4 what results to image pixelation. Would be good to have an option to set limit for the maximal zoom to control cropped image oversizing.

No tags in this repo causing error in CocoaPods: "Could not find remote branch 0.4.5 to clone"

I checked that there's no tag or release on GitHub, https://github.com/brynbodayle/BABCropperView/releases, and I think that's why pod install is falling because it can't find that tag while trying to clone the repo at that tag.

To fix it, I think you need to push your tags onto GitHub by running this in your terminal

git push --tags

Podfile:

pod 'BABCropperView', '~> 0.4.5'

Log:

> pod install
Updating local specs repositories
Analyzing dependencies
Downloading dependencies
Installing BABCropperView (0.4.5)

[!] Error installing BABCropperView
[!] /usr/local/bin/git clone https://github.com/brynbodayle/BABCropperView.git /var/folders/9x/zk40rlgn7sqc5rl6rl_qjs1h0000gn/T/d20160121-8474-1879es3 --single-branch --depth 1 --branch 0.4.5

Cloning into '/var/folders/9x/zk40rlgn7sqc5rl6rl_qjs1h0000gn/T/d20160121-8474-1879es3'...
warning: Could not find remote branch 0.4.5 to clone.
fatal: Remote branch 0.4.5 not found in upstream origin

My temporary workaround is to specify a commit in Podfile rather than a tag for BABCropperView.

pod 'BABCropperView', :git => 'https://github.com/brynbodayle/BABCropperView.git', :commit => 'af6c17a'

PS.

Great work! Thanks for your effort for making this lovely framework!

Get CGRect of cropping rectangle

It would be really great if there was property to get CGRect of cropping rectangle, like 'UIImagePickerControllerCropRect' key in UIImagePickerControllerDelegate protocol:

Specifies the cropping rectangle that was applied to the original image.
The value for this key is an NSValue object containing a CGRect opaque type.

Or any suggestion how to get it would be appreciated. Great library btw, saved me a lot of time.

When trying to crop image to a smaller size, image auto scales up to full width

Hello,

When you pinch zoom out an image to a smaller size, the image autoscales back up to fill the entire width. In this case, user needs a third hand to keep the image pinched while tapping the crop button. Is it possible externally to modify this behaviour?

Current behavior = image jumps back to match its width to crop area width

Proposed behaviour = image jumps back to fill width or height of the crop area, whichever is hit first. This way it would be easier for a user who for example wants to include the entire height of a portraid picture in a square

Is there an easy way to override this behaviour?

Error with cocoapod beta 6

Hi! I trying to build project with your pod. My cocopod version is 1.0 beta 6

I've got this error:

error: /Users/alexey/Library/Developer/Xcode/DerivedData/Tipster-ghedtvicbrrnxbbbvlmlwydvyhet/Build/Products/Debug-iphonesimulator/BABCropperView/BABCropperView.bundle: No such file or directory

Can you delete bundle resources from podspec?

Transparent image cropping problem.

When i try to crop a transparent image, this library is not working properly. it is making background black. please check with this testing image.
eleptest

Real resolution

Can I crop image by 200x200 but have whole resolution of image?
Example: I have image 4000x3000, show crop size 200x200 on screen and after crop I have 200x200. But real resolution 3000x3000. Can I get it?
Thanks!

Small images bug

Hi there, this lib is by far one of the best I found after a long time of surfing internet.

However there is a small detail when select small images using a particular crop size:

I'm using crop size 720 * 240 and I'm using this image:
http://www.thetechchat.com/wp-content/uploads/2012/08/Microsoft-Logo.jpg you can download it from safari on simulator.

when prompted to pick it displays the picture like this :
screen shot 2015-07-07 at 11 00 45 pm

which is ok like that because the user might not want to scale it, and just when you tap crop... this happen

screen shot 2015-07-07 at 11 00 51 pm

  1. Is there a way to keep it centered and not aligned to the right?
  2. Is there is a way to keep the background transparent? not black or at least white?

Cheers!.

Return cropped image nil

Same as issue #11

It looks like for image I took from camera it doesn't work.

A not working image always not work (but if I use the iOS default editing tool do some edit and save, then it works).

Images from screenshot or from other sources always work.

Attached is a couple of not working samples FYI (same image works on Emulator but not on real device)

Return cropped image nil

Hi

Control is really nice.

I am using crop with the custom scale size but sometimes cropped image returning nil.
Please let me know what could be the issue?

Thanks

Full Image

I want to keep whole part of image.
Means no parts of image should be cropped.

if image is landscape image, then it should be converted into square image with black space on top and bottom

Cropping with Excess

Love the library! The issue board has been a great help and I am hoping to find an answer here :)

I am using this library to allow a user to crop an image into a 16:9 ratio image; however, when cropping, if the original image was portrait, there is excess space sometimes on the sides. When I crop, this space is then added to the photo. Is there a way that I can adjust the image size to include the proper cropping frame, but not the excess? I have been playing around with the values: x.allowsNegativeSpaceInCroppedImage and x.allowsNegativeSpaceInCroppedImage, however, they do not seem to work in this way.

Suggestions?

Rotation issue

I'm Using BABCropperView (0.4.6). For some reason the photos I take with my device are falling into case UIImageOrientationRight thus being rotated by BAB Cropper

I don't fully understand what UIImageOrientation stands for and if this is expected.
I'd like to know if there is a way to disable the rotation of the image by the cropper or to correct (?) the orientation of my photo before cropping it

Thank you very much!

Unexpected cropping issues on real devices

Hello,
i have noticed that last changes have broken the project.
When i run example project on iPhone 6+ (iOS 9.0) and choose taken photos (with imageOrientation == UIImageOrientationRight) - there is always the same result: cropped photo not rotated and not cropped actually.
Original ImageResult Image

Cropping bug

It looks like the bug with small pictures, however the pictures are not so small..

For example I use default pictures from iOS simulator

screen shot 2015-12-06 at 5 01 37 pm

screen shot 2015-12-06 at 5 01 41 pm

Here is my code. The view is view of controller that is fullscreen size

babCropper.cropSize = CGSizeMake(view.bounds.width, view.bounds.width * 1.2)

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.