heitorfr / ios-image-editor Goto Github PK
View Code? Open in Web Editor NEWiOS View Controller for image cropping. An alternative to the UIImagePickerController editor with extended features.
License: MIT License
iOS View Controller for image cropping. An alternative to the UIImagePickerController editor with extended features.
License: MIT License
If I tell it to output at 1500 it will output at 1500 x 1502.
I've tried to implement your part of code which launches DemoImageEditor from a basic view controller instead of starting if from the AppDelegate and I have an issue in MY code : "[DemoImageEditor setCropRect:]: unrecognized selector sent to instance" because is not HFImageFrameView which launches setCropRest but the own view. And I don't understand why. Basicaly I have a simple view with a button. I push the button to start UIImagePickerController in a (void) displayImagePickerWithSource where the *picker is instantieted with *library and *imageEditor which will be pushed to the DemoImageEditor.
If someone attempts to select and save a Panaroma image being feed it to HFImageEditViewController memory warnings are thrown and the device resets. Upon running on an iPhone 5 with Instruments, when a user attempts to crop and save (doneAction:) memory allocations spike to over 1.5 gb.
First, I'm setting it after initialization. Then I'm changing it in viewDidLoad method of my subclass. Checking is still turned on and I can't see any of 'outside' area into my image.
RCImageEditorViewController *viewController = [[RCImageEditorViewController alloc] initWithNibName:@"RCImageEditorViewController" bundle:nil];
[viewController setCheckBounds:YES];
// subclass
(void)viewDidLoad {
[super viewDidLoad];
self.checkBounds = NO;
}
When first going into the image editing screen, the image appears blurry/ not focused for a couple seconds. Great library overall, but this bug will need to be fixed. Thanks!
I found that I can't pan the image smoothly. When I pan the image upward, downward, to the right or to the left, it bounds the image to the original position.
I can, hardly to succeed, pan the image, when I pan it very very slowly.
May I ask for any measure that I can make to correct my situation?
I have set the "checkBounds" to "YES".
Thanks.
Can I bound image to not scale below to corp area, as of now i can scale image as smaller then corp area. that's why at the time I am corp the image black background will come with result image.
Dec 1 11:49:13 Daniels-MacBook-Pro.local ImageEditor[72522] : CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component color space; kCGImageAlphaLast; 4096 bytes/row.
Dec 1 11:49:13 Daniels-MacBook-Pro.local ImageEditor[72522] : CGContextSetInterpolationQuality: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
Dec 1 11:49:13 Daniels-MacBook-Pro.local ImageEditor[72522] : CGContextTranslateCTM: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
Dec 1 11:49:13 Daniels-MacBook-Pro.local ImageEditor[72522] : CGContextConcatCTM: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
Dec 1 11:49:13 Daniels-MacBook-Pro.local ImageEditor[72522] : CGContextDrawImage: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
Dec 1 11:49:13 Daniels-MacBook-Pro.local ImageEditor[72522] : CGBitmapContextCreateImage: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
Hi, this is great, thank you.
I'm just wondering, when I resize an image smaller than the crop area, or move it outside the crop area, the blank space left behind appears white in the crop area, however the resulting image that is processed has black for the blank space.
Is there any way to sync these? I don't mind setting the crop view to show black or the result to use white, as long as they are the same?
Thanks
Hi Heitorfr,
i have issues using your editor with storyboard.
i'm getting uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil' error.
how do i initialise it ?
cheers
des
Hello, It would be nice that instead of rejecting a pan action that gives a invalid pan that instead of rejecting it that it tries to correct it or at least limits the transforme so that the values do not go beyond the edges. the way it is now it difficult to get the image to the edges for example: right after the initial load try to set the image to the top left corner. you will not be able to get the top part.
I set rotateEnabled to 'NO' in the demo application, and after rebuilding, rotation is still enabled in the editor.
When trying to rotate and crop panorama images application crashes with message "Terminated due to memory error".
If images is not rotated before cropping then it works fine.
Works fine with normal images.
Any workaround for this?
When i change the size if the cropsize lets say a size of 100x100, i obtain a sourceImageView as small as the cropView.
I have tried to change the cropzise without a reset, also i tried to change the size of the frame of the sourceimageView, it works sourceImageview big, cropView small. but then when i crop the result image its not the same one i selected to crop. (its like a crop of the upper part of the original crop selection)
I have read the code and tried to make changes so that i achieve the correct effect but im not able to do it so far. i think is related with the scale and the image transforms are done during the save operation.
I found 1.1.3 version of ios-image-editor.podspec file.
https://github.com/CocoaPods/Specs/blob/master/ios-image-editor/1.1.3/ios-image-editor.podspec
But could not find the 1.1.4 version file.
Please add new .podspec file.
Best regards.
if i scale the image with a very small size, then the image will jump out of the crop box, and may be jump out of screen.
how can i make cricle crop by this code
it can show the image like before, but not able to crop it any longer
Hello, hopefully I'm just doing something wrong here, but despite setting the cropSize property, I'm always getting a square crop area. Here's my code:
HFImageEditorViewController *imageEditor = [[HFImageEditorViewController alloc] initWithNibName:@"ImageCropperView" bundle:nil];
imageEditor.cropSize = CGSizeMake(312.0, 416.0);
imageEditor.sourceImage = myImage;
imageEditor.doneCallback = ^(UIImage *editedImage, BOOL canceled){
if (canceled) {
//do nothing
} else {
[self.myImageView setImage:editedImage];
}
[self.navigationController popViewControllerAnimated:NO];
};
[self.navigationController pushViewController:imageEditor animated:NO];
My "ImageCropperView" xib contains a toolbar at the bottom with the "done" and "cancel" buttons, and the frameView (of type HFImageEditorFrameView) fills the rest of the view.
...It doesn't seem that the value of imageEditor.cropSize has any effect whatsoever on the actual size of the crop rectangle. Otherwise, everything works swimmingly.
Any help would be immensely appreciated! Thanks.
its working fine.but when i take photo and click back button in navigation bar camera vieww is freeze.
u have any idea.
Right now the crop rect has to be centered for the image to output correctly.
I'd like to be able to define the position of the crop rect.
Is it possible to add the crop rect (x,y,width,height) of the new cropped image relatively to the original one?
Hello I am trying to set a method to di a 90degree left or right rotation.
this as a side effect that the bound checking becomes invalid.
Not sure if I not setting some this I should or should not.
But this is my code below that I added to the HFImageEditorViewController
(void) rotate:(ImageRotationDirection)pOrientation
{
CGFloat rotation = 0;
if (pOrientation == ImageRotationDirectionRight)
{
rotation = M_PI_2;
}
else
{
rotation = -M_PI_2;
}
CGAffineTransform transform = CGAffineTransformRotate(self.imageView.transform, rotation);
CGRect rectA = self.imageView.frame;
rectA = CGRectApplyAffineTransform(rectA, transform);
CGFloat scale = self.cropRect.size.width/rectA.size.width;
transform = CGAffineTransformScale(transform, scale/self.scale, scale/self.scale);
[self checkBoundsWithTransform:transform];
self.imageView.transform = self.validTransform;
}
Hi
I am trying to add this to my project and noticed that I keep getting the following error:
/Users/gkemp/Documents/Inviqa/wowlive/wowlive/wowlive-Bridging-Header.h:8:9: 'ios-image-editor/HFImageEditorFrameView.h' file not found
when I can see the files in my Pods folder.
Can anyone advise how to import using swift bridging header?
eg
#import <ios-image-editor/HFImageEditorFrameView.h>
When creating a XIB that uses Auto Layout and wiring everything up as described in the README, using a 320x320 frameView
that has a centered X and Y, the image in the cropper is displayed slightly lower than the intended frame. This only occurs on the iPhone 4/4s and does not occur on the 5/5s.
See attached image.
Would it be possible to make the crop square have rounded corners?
I already clip the image's corners, but would like it to be visible to the user where it will be clipped.
Any pointers?
Thanks
Hello,
I'm using your library, I want that the picture don't be able to go out of the cut area.
I almost achieve this with the following modifications in the code:
The code is working but have a bug with the pitch, I would like to discuss this with you, please take a look to the code. Thanks!
For the Pan:
- (IBAction)handlePan:(UIPanGestureRecognizer*)recognizer
{
if([self handleGestureState:recognizer.state]) {
CGPoint translation = [recognizer translationInView:self.imageView];
float availableXmove = self.imageView.frame.size.width - self.cropSize.width;
float availableYmove = self.imageView.frame.size.height - self.cropSize.height;
if ((availableXmove>0) || (availableYmove>0)){
float availableXmoveLeft = (availableXmove / 2) - (_totalMoveX + (translation.x * self.scale));
float availableXmoveRight = (availableXmove / 2) + (_totalMoveX + (translation.x * self.scale));
float availableYmoveTop = (availableYmove / 2) + (_totalMoveY - (translation.y * self.scale));
float availableYmoveButton = (availableYmove / 2) - (_totalMoveY - (translation.y * self.scale));
if ((availableXmoveLeft>=0) && (availableXmoveRight>=0) &&
(availableYmoveTop>=0) && (availableYmoveButton>=0)){
//NSLog(@"puedo mover por X o Y");
float avaliableX = ((availableXmove) / 2);
_totalMoveX += translation.x * self.scale;
if ((avaliableX>_totalMoveX) && ((-1*avaliableX)<_totalMoveX)){
CGAffineTransform transform = CGAffineTransformTranslate( self.imageView.transform, translation.x, 0);
self.imageView.transform = transform;
[recognizer setTranslation:CGPointMake(0, 0) inView:self.frameView];
}else{
_totalMoveX -= translation.x * self.scale;
}
float avaliableY = ((availableYmove) / 2);
_totalMoveY -= translation.y * self.scale;
if ((avaliableY>_totalMoveY) && ((-1*avaliableY)<_totalMoveY)){
CGAffineTransform transform = CGAffineTransformTranslate( self.imageView.transform, 0, translation.y);
self.imageView.transform = transform;
[recognizer setTranslation:CGPointMake(0, 0) inView:self.frameView];
}else{
_totalMoveY += translation.y * self.scale;
}
}
}else{
//NSLog(@"Err");
}
}
}
For the Pinch:
- (IBAction)handlePinch:(UIPinchGestureRecognizer *)recognizer
{
if([self handleGestureState:recognizer.state]) {
if(recognizer.state == UIGestureRecognizerStateBegan){
self.scaleCenter = self.touchCenter;
}
float availableXmove = self.imageView.frame.size.width - self.cropSize.width;
float availableYmove = self.imageView.frame.size.height - self.cropSize.height;
availableXmove = availableXmove / 2;
availableYmove = availableYmove / 2;
float availableXmoveLeft = availableXmove - _totalMoveX;
float availableXmoveRight = availableXmove + _totalMoveX;
float availableYmoveTop = availableYmove + _totalMoveY;
float availableYmoveButton = availableYmove - _totalMoveY;
if ((availableXmoveLeft>=0) && (availableXmoveRight>=0) &&
(availableYmoveTop>=0) && (availableYmoveButton>=0)){
NSLog(@"ok");
if ( self.scale*recognizer.scale>=1){
CGFloat deltaX = 0;//self.scaleCenter.x-self.imageView.bounds.size.width/2.0;
CGFloat deltaY = 0;//self.scaleCenter.y-self.imageView.bounds.size.height/2.0;
CGAffineTransform transform = CGAffineTransformTranslate(self.imageView.transform, deltaX, deltaY);
transform = CGAffineTransformScale(transform, recognizer.scale, recognizer.scale);
transform = CGAffineTransformTranslate(transform, -deltaX, -deltaY);
self.scale *= recognizer.scale;
self.imageView.transform = transform;
recognizer.scale = 1;
}
}else{
NSLog(@"Err");
}
}
}
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.