0

I am new to iOS development and I really need some help in a task. I need to know how does the cropping and re-sizing image is done in Objective-C. For registration I need to select a profile image and then I want to crop and resize it, But I am unaware how to do it. I have seen many source codes in Github and at SO but none of them seems to help out. Can anyone guide me how does the cropping image work in iOS?

Here is the screenshot of my page I'm working on-

Screenshot

Rahul Vyas
  • 28,260
  • 49
  • 182
  • 256

2 Answers2

2

Why you are not using standard UIImagePickerController? If you set imagePicker.allowsEditing = YES; and then in imagePickerController:didFinishPickingMediaWithInfo delegate method get

UIImage *newImage = info[UIImagePickerControllerEditedImage];

you'll get the image cropped by user.

Sunny
  • 137
  • 7
1

you can use this function Pass an image and size in it and get image in return.

+ (UIImage*)imageWithImage:(UIImage*)image 
               scaledToSize:(CGSize)newSize;

{

   UIGraphicsBeginImageContext( newSize );

   [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];

   UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();

   UIGraphicsEndImageContext();

   return newImage;

}
Bhavin Bhadani
  • 22,224
  • 10
  • 78
  • 108
Krish Solanki
  • 269
  • 4
  • 11