Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of the black ground on the image returned from UIImagePickerControllerEditedImage when using UIImagePicker

When using UIImagePicker, it allows to get into Edit mode. Then for an image taken with landscape mode, if user don't scale it manually within the UIImagePicker, there would have black stripe/background on the top and bottom of the image. Is there a way to get rid of that and make that portion of the image to be transparent?

like image 320
tom Avatar asked Jan 23 '26 02:01

tom


1 Answers

#pragma mark UIImagePickerControllerDelegate

- (void)imagePickerController:(UIImagePickerController *)picker  didFinishPickingMediaWithInfo:(NSDictionary *)info {

    UIImage *img = nil;

    CGRect cropRect = [[info valueForKey:UIImagePickerControllerCropRect] CGRectValue];

    if (cropRect.origin.y < 0) {

        img = [info objectForKey:UIImagePickerControllerOriginalImage];

    } else {

        img = [info objectForKey:UIImagePickerControllerEditedImage];

    }

}
like image 69
steamx Avatar answered Jan 24 '26 16:01

steamx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!