ruslanskorb / rskimagecropper Goto Github PK
View Code? Open in Web Editor NEWAn image cropper / photo cropper for iOS like in the Contacts app with support for landscape orientation.
License: MIT License
An image cropper / photo cropper for iOS like in the Contacts app with support for landscape orientation.
License: MIT License
Hey Ruslan,
I'm trying to changing radius in the maskRect (want to make it small), but it's looks like dataSource Protocol stop working.
I use the following code:
RSKImageCropViewController *imageCropVC = [[RSKImageCropViewController alloc] initWithImage:image];
imageCropVC.delegate = self;
imageCropVC.dataSource = self;
[self presentViewController:imageCropVC animated:nil completion:nil];
delegate are working, but the dataSource are not.
Could you please have a look? And yes, I have not forgot to add :)
Btw, thank you for the great framework!
Regards,
Anton
I want to create cropping image view like whats up ? so can you help me for same.
Thanks for this cool library!
In example project, in Images.xcassets
, add an image as 2x (or 3x) for photo
, then build on a retina screen. Cropped image does not match cropped area at all.
It seems that scale is not handled correctly when generating cropRect
(and the resulting croppedImage).
Note that any generated UIImage will have a scale of 2 on retina devices (ex: an image fetched online).
Hi, I don't know if I understand the library correctly, but if you see this example app I did with your code http://cl.ly/ZLhB you will notice that the resulting croppedImage is changing when I scale the underlaying image.
Is this correct? shouldn't the returned croppedImage
always be in the same size?
Because [UIApplication sharedApplication]
is not accessible in app extensions.
The common way of solving this is adding a macro "APP_EXTENSION=1" for the app extension target and checking for it.
It seems you only use it for status bar purposes. You should know that status bar behaves really weird in app extensions (inherit parent app behavior, NOT customizable), so not trying to define/style it if in an app extension would work.
Hi, thanks for this control :)
This is an enhancement request, I don't want to show cropper view controller, please provide a direct method which take an image as input and give cropped output with given size.
Hello, I am trying to implement a UIImagePicker with custom cropper. I have searched for a similar error and the answer was "the imageCropViewControllerCustomMaskPath wasn't implemented", but I have implemented mine, so I'm not sure what's the issue here. Any help would be appreciated. Thanks in advance.
//UIImagePickerControllerDelegate
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) {
picker.dismissViewControllerAnimated(true) { () -> Void in
let imageCropVC = RSKImageCropViewController(image: image, cropMode: RSKImageCropMode.Custom)
imageCropVC.delegate = self
self.presentViewController(imageCropVC, animated: true, completion: nil)
}
}
//RSKImageCropViewControllerDelegate, RSKImageCropViewControllerDataSource
func imageCropViewControllerDidCancelCrop(controller: RSKImageCropViewController) {
dismissViewControllerAnimated(true, completion: nil)
}
func imageCropViewController(controller: RSKImageCropViewController, didCropImage croppedImage: UIImage, usingCropRect cropRect: CGRect) {
//Do some stuff here with the image.
dismissViewControllerAnimated(true, completion: nil)
}
func imageCropViewControllerCustomMaskRect(controller: RSKImageCropViewController) -> CGRect {
//let maskSize = CGSizeMake(320, 320)
let maskRect = CGRectMake(0 , 30, 260, 260)
return maskRect
}
func imageCropViewControllerCustomMaskPath(controller: RSKImageCropViewController) -> UIBezierPath {
let rect = controller.maskRect
let point1 = CGPointMake(CGRectGetMinX(rect), CGRectGetMaxY(rect))
let point2 = CGPointMake(CGRectGetMaxX(rect), CGRectGetMaxY(rect))
let point3 = CGPointMake(CGRectGetMidX(rect), CGRectGetMinY(rect))
let triangle = UIBezierPath()
triangle.moveToPoint(point1)
triangle.moveToPoint(point2)
triangle.moveToPoint(point3)
triangle.closePath()
return triangle;
}
func imageCropViewControllerCustomMovementRect(controller: RSKImageCropViewController) -> CGRect {
let rect = controller.maskRect
return rect;
}
Error is:
Jan 4 19:54:40 App[10148] <Error>: CGAffineTransformInvert: singular matrix.
Jan 4 19:54:40 App[10148] <Error>: CGAffineTransformInvert: singular matrix.
Jan 4 19:54:40 App[10148] <Error>: CGAffineTransformInvert: singular matrix.
Hi, thanks for the great component! This is 98% of what I need. The 2% is I need to be able to change the diameter of the crop circle and change the crop layer color to something other than black. Will you be able to do this or should I submit a pull request? Thanks again!!!
Hi,
I would like to congratulate you for making such an excellent control.
However can you provide solution from triangular crop as you have already added circular and square shape
With last 1.5.0 update my compilation fails when installing the library using Cocoapods, complaining it can't find the file.
I am using RSKimageScrollView (amongst others) in my code, but noticed in the last update only a few headers were exposed:
s.public_header_files = [ 'RSKImageCropper/RSKImageCropper.h', 'RSKImageCropper/RSKImageCropViewController.h', 'RSKImageCropper/RSKImageCropViewController+Protected.h' ]
I wonder if this was intended?
My assumption is it's a mistake as it breaks backwards compatibility for some use cases of the library.
Have a PR ready that fixes the issue in case I'm right. #93
Using RSKImageCropModeSquare does not always return a perfect square for every image I crop. For example cropping this image at minimum zoom produces an image of 418 x 417
And this image comes out at 405 x 404
However cropping this image produces an image of 437 x 437
It is important for me that a perfect square is returned.
avoidEmptySpaceAroundImage is set in both cases.
Any help would be great.
Thanks
It'll great if you add cropping to UIImagePickerController when allowsEditing is set to YES. Default frame is square.
Hi, i'm trying to use this amazing library, but i have a problem, when i dismiss the RSKImageCropperViewController the status bar become black, instead in my app i have a light color status bar. how i can fix it?
Maybe it will great add image cropper as UIView inherit, not UIViewController for easy customization? Thanks
I get squared image returned in the delegate even when the controller created in RSKImageCropModeCircle.
How do I prohibit it?
Hi, first of all, thanks for this amazing library :)
I'm trying to use a custom size rect to crop and image, so I'm using this:
RSKImageCropViewController *imageCropVC = [[RSKImageCropViewController alloc] initWithImage:image cropMode:RSKImageCropModeCustom];
imageCropVC.delegate = self;
imageCropVC.dataSource = self;
Then, I implemented the delegate and data source methods like this
- (CGRect)imageCropViewControllerCustomMaskRect:(RSKImageCropViewController *)controller
{
CGSize maskSize;
CGFloat maskWidth = [UIScreen mainScreen].bounds.size.width;
CGFloat maskHeight = ceilf(self.view.frame.size.height * 0.4f);
NSLog(@"MASK WIDTH: %f", maskWidth);
NSLog(@"MASK HEIGHT: %f", ceilf(maskHeight));
maskSize = CGSizeMake(maskWidth, maskHeight);
CGRect maskRect = CGRectMake((self.view.frame.size.width - maskSize.width) * 0.5f,
(self.view.frame.size.height - maskSize.height) * 0.5f,
maskSize.width,
maskSize.height);
return maskRect;
}
- (UIBezierPath *)imageCropViewControllerCustomMaskPath:(RSKImageCropViewController *)controller
{
CGRect rect = controller.maskRect;
CGPoint point1 = CGPointMake(CGRectGetMinX(rect), CGRectGetMinY(rect));
CGPoint point2 = CGPointMake(CGRectGetMaxX(rect), CGRectGetMinY(rect));
CGPoint point3 = CGPointMake(CGRectGetMaxX(rect), CGRectGetMaxY(rect));
CGPoint point4 = CGPointMake(CGRectGetMinX(rect), CGRectGetMaxY(rect));
UIBezierPath *rectangle = [UIBezierPath bezierPath];
[rectangle moveToPoint:point1];
[rectangle addLineToPoint:point2];
[rectangle addLineToPoint:point3];
[rectangle addLineToPoint:point4];
[rectangle closePath];
return rectangle;
}
- (CGRect)imageCropViewControllerCustomMovementRect:(RSKImageCropViewController *)controller
{
return controller.maskRect;
}
And, on my console (texting with an iPhone 6S) I'm getting this:
2016-02-09 17:36:28.705 HorseWare[716:140715] MASK WIDTH: 375.000000
2016-02-09 17:36:28.705 HorseWare[716:140715] MASK HEIGHT: 267.000000
2016-02-09 17:37:05.540 HorseWare[716:140715] CROPPED IMAGE SIZE: 1936.000000, 1125.000000
2016-02-09 17:37:05.540 HorseWare[716:140715] CROPPED RECT SIZE: 1936.000000, 1125.000000
So, I'm not getting the same size neither the same aspect ratio for the custom rect mask.
MASK WIDTH / MASK HEIGHT = 1.40
CROPPED RECT WIDTH / CROPPED RECT HEIGHT = 1.72
Why is that happening?
Thanks for your time
I have downloaded the source and trying to run But as I open workspace but didn't able to compile the code... Pods are missing.What I need to run this source code.
Instagram photos are 640 x 640 pixels in size. I would like to make this the minimum size that an image can be cropped to. Could you (or anyone) suggest how I might go about achieving this?
I have encountered this issue when I try to reload a panoramic image (10mb) in RSKImageCropViewController.
Steps:
In step 4, I can see the image is displayed in the RSKImageCropViewController but now crashes. If I load images with lower file size, it can handle it.
I'm not sure where to handle this error or are there any workarounds on this?
Thank you.
(sorry, mistakenly pressed close issue)
Would be great if you will add rotation feature. Thanks
I set the RSKImageCropMode = RSKImageCropModeSquare , when I zoom the image smaller ,the MaskRect is smaller with image, not to be a square . can we fixed the size and not changed with image zoom
Hi ,
I installed this library using pods. Currently I am working on Xcode 7.0.1
After pod installation , I imported
#import <RSKImageCropper/RSKImageCropper.h>
in MyProject-Bridging-Header.h
It is showing an error No such module
used RSKImageCropModeCustom have error.
Thank you!
Hey, could you tell me how to calculate correct avoidness for empty space around image using rectangle, which formalus did you use to do it for Square, because it works perfectly fine!! If i am trying to do it for rectangle sometimes it doesn't avoid empty space. Help will be appreciated. Thanks.I attached image to see how it looks like
Hi
I added a functionality to rotate the image by ninety degrees clockwise, the functionality is disabled by default and can be enabled setting the parameter '''fixedRotationEnabled''' to YES, this shows a button that allows the rotation. Also added a few test for this.
I have a fork with the changes (https://github.com/estebansotoara/RSKImageCropper/tree/ninetyDegreesRotation), you can check it out and if you like it I can make a PR
BTW: there are 8 test that are failing, checked on a clean copy of master and are failing there too so idk if it is a known issue or just failing to me for some strange reason
Things I'd like if you're adding tests for this project:
Tooling: Specta/Expecta, XCTest
Areas to look at:
Notes:
when i use pod 'RSKImageCropper', and run pod install, i found that the code missing the custom UI feature?
/**
The mode for cropping.
*/
@Property (assign, nonatomic) RSKImageCropMode cropMode;
/// -------------------------------------------
/// @name Checking of the Interface Orientation
/// -------------------------------------------
/**
Returns a Boolean value indicating whether the user interface is currently presented in a portrait orientation.
@return YES if the interface orientation is portrait, otherwise returns NO.
*/
color,alpha,button...
Hello,
Thanks a lot for the great library. I'd love to have support for a custom cropSize at runtime. You could simply add a boolean resizable variable and if it's set to true, the edges of the maskLayer can be dragged (to increase or decrease the width and the height of the mask).
Let me know if you are going to add this feature :)
Thanks.
Patrick
It would be nice to be able to provide table and bundle name, which RSKImageCropper would use in all NSLocalizedString calls. Currently with Pods localization is not possible.
Hi,
I'm trying to use your pod in my project that's developed using Swift, but after installing it I get the following error:
/Users/william_oanta/Agilio/iOS-App/Pods/RSKImageCropper/RSKImageCropper/CGGeometry+RSKImageCropper.h:26:9: Include of non-modular header inside framework module 'RSKImageCropper.CGGeometry_RSKImageCropper'
I have set in Build Settings 'Allow Non-modular Includes in Framework Modules to YES for both the Live Vicarious and the Pods workspace, and it is still not working.
Here you have some screenshoots:
I have tried your demo example and it's working on the same environment - but I saw that you don't use Swift, and I guess this is a Swift caused problem. Any clue on how to fix it?
Thanks
If I have a picture taken in iphone landscape mode. The cropper view gets the image turned 90degree left. How can I make it not to turn the image at any condition ? By the way sorry if my English is bad.
Hi there,
I don't seem to be able to compile the example project due to podfile errors. 'pod install' ran fine, but xCode tells me
diff: /../Podfile.lock: No such file or directory
diff: /Manifest.lock: No such file or directory
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
Do you know what this could mean?
Thanks and regards,
Sebastian Mecklenburg
I want to cut image in square , i changed this line _cropMode = RSKImageCropModeCircle to
RSKImageCropModeSquare but not working
I wanted to suggest that you make the following variables parameters, or at least make them available for change by including them in the .h file. I want to eliminate the space around my circle mask so that it fills the screen width-wise. Also, for iPhone 4S and showing the crop view controller in a popover in the iPad, the "move and scale" label is right on top of the crop area.
//static const CGFloat kPortraitCircleMaskRectInnerEdgeInset = 15.0f;
//static const CGFloat kPortraitSquareMaskRectInnerEdgeInset = 20.0f;
static const CGFloat kPortraitCircleMaskRectInnerEdgeInset = 0.0f;
static const CGFloat kPortraitSquareMaskRectInnerEdgeInset = 0.0f;
//static const CGFloat kPortraitMoveAndScaleLabelVerticalMargin = 64.0f;
static const CGFloat kPortraitMoveAndScaleLabelVerticalMargin = 30.0f;
//static const CGFloat kLandscapeCircleMaskRectInnerEdgeInset = 45.0f;
//static const CGFloat kLandscapeSquareMaskRectInnerEdgeInset = 45.0f;
static const CGFloat kLandscapeCircleMaskRectInnerEdgeInset = 0.0f;
static const CGFloat kLandscapeSquareMaskRectInnerEdgeInset = 0.0f;
Hi there,
I loved the library for circular and square crops, although I am having trouble with custom size crops.
I've initiated the RSKImageCropViewController
with the custom size parameter and also implemented the RSKImageCropViewControllerDataSource
in my own controller, but the method imageCropViewControllerCustomMaskRect
is never called.
// Instantiation:
RSKImageCropViewController *cropViewController = [[RSKImageCropViewController alloc] initWithImage:self.selectedImageButton.originalImage
cropMode:RSKImageCropModeCustom];
// Delegate method:
- (CGRect)imageCropViewControllerCustomMaskRect:(RSKImageCropViewController *)controller {
NSLog(@"Test");
return CGRectMake(0, 0, 250, 250);
}
What I really want is to define a custom rect for the cropper every time it is called. If I could do it in the initiation method, that'd be great but it looks like the only way is to implement the delegate method, which is not working for me.
What may I be doing wrong?
Thanks
Could you make readwrite rotationAngle? I would like to reset angle during cropping, thanks.
Hi gents, I've tried rectangle mode (for quick testing I've used square mode, but change this in source code CGSize maskSize = CGSizeMake(length, length * 0.75));
And here the result https://www.dropbox.com/s/lp2yuhx0lnzoubu/Screenshot%202015-03-13%2018.05.19.png?dl=0
avoidEmptySpaceAroundImage not working with rectangle mode for me, but perfect with square.
Or how should I create rectangle mode then? Thanks.
When I select the image by tapping "Choose" after editing, I get the following errors. Have no idea why this is happening.
Dec 1 15:32:35 MyApp : CGBitmapContextCreate: unsupported parameter combination: set CGBITMAP_CONTEXT_LOG_ERRORS environmental variable to see the details
Dec 1 15:32:35 MyApp : CGContextSetInterpolationQuality: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Dec 1 15:32:35 MyApp : CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Dec 1 15:32:35 MyApp : CGContextConcatCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Dec 1 15:32:35 MyApp : CGContextDrawImage: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Dec 1 15:32:35 MyApp : CGBitmapContextCreateImage: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
The cropped image is returned in the delegate method, but the original image is not returned. This is an issue if, for example, we call RSKImageCropper from
Unless we save the original image into a property at this point, we lose it. It would be a handy option to return the original image in the delegate method for RSKImageCropper.
Hello !
Please help me. How to make sure the image always fills the aspect ratio-don't allow any back space.
I have review your source code , Mind blowing cropping work But It actually cropping in rectangular form not in circular form ,It seem like you are showing the rectangular(cropped image) into circular form .
Can you tell me how to crop a image in proper circular and oval shape.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.