UIImagePickerController* libraryUI = [[UIImagePickerController alloc] init];
libraryUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
libraryUI.delegate = self;
libraryUI.allowsEditing = YES;
[self presentViewController:libraryUI animated:YES completion:nil];
I am using this code to open image picker view and pick an image from gallery. I also set the property "allowsEditing" to "YES" in order to enable the crop image functionality. Now the main issue is that the picker view opened with rectangular crop option. What I want is to get circular crop image option and also want to set the crop circle size (increase or decrease crop circle size).
Since it is not available by default, I will suggest you to use this library:
TOCropViewController
It comes with some other features other than circular crop as well. Objective-C and Swift versions are both available
Related
I used an UIImage to initialize an MGLImageSource. Then I use the MGLImageSource to initialize a MGLRasterStyleLayer and I add the layer to a MGLMapView. It turned out that the image is too big to fit entirely into the map view. How do I tell MGLMapview to scale an image automatically so that the image fits entirely into the view like the 'scale to fit' in iOS ? thanks !
Here is how I add the image into the map view:
UIImage *radarImage = [UIImage imageNamed:#"radar.png"];
MGLImageSource *source = [[MGLImageSource alloc] initWithIdentifier:#"radar" coordinateQuad:coordinates image:radarImage];
[style addSource:source];
MGLRasterStyleLayer *radarLayer = [[MGLRasterStyleLayer alloc] initWithIdentifier:#"radar-layer" source:source];
[style addLayer: radarLayer];
set a property of mapview called visibleCoordinates; it has two members SW and NE which stands for the top right corner and low left corner of the visible view. That will restrict the size of the image and automatically resize the image.
In my view I have a UIView that I use to preview the camera. It's a lot smaller than the regular preview view (128x128). I initialise the UIImagePickerController like this:
self.picker = [[UIImagePickerController alloc] init];
self.picker.delegate = self;
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
self.picker.showsCameraControls = NO;
self.picker.view.frame = self.profilePictureView.frame;
I then use [v addSubview:self.picker.view]; to show the camera's preview within my custom UIVIew. So far this works as intended, I see the part of the camera preview that overlaps my custom view in that view (essentially masking the preview with my custom view).
Now I'm trying to get what is displayed in my UIView into a UIImage (resulting in a 128x128 image). I tried using the delegation methods, but I only get the full size image from the camera there. I also tried taking a screenshot from the view but I got lost...
How can I create a UIImage with the exact same content as the view I use to render the camera preview, including size, offset and ratio?
I take photos using UIImagePickerController, source type is UIImagePickerControllerSourceTypeCamera.
After i captured, the image editing is changing depending upon the orientation. Herewith i attached my snapshot.
Image 1 : i took this image in portrait mode.
Image 2 : i took this image in landscape mode. here, the top portion is in black color.
My code is :
UIImagePickerController *pickerCamera = [[UIImagePickerController alloc] init];
pickerCamera.delegate = self;
pickerCamera.allowsEditing = YES;
pickerCamera.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:pickerCamera animated:YES completion:NULL];
I want to rotate the image to portrait. Please help me to solve this issue.
I have seen several apps that after you take a picture, it shows a view for Move and Scale your picture, with a box showing what the resulting image will look like. My app takes a picture the user takes or picks from library, and adds it to a PDF file. I need this file to be a certain size to fit on the PDF, so I need to set the move and scale box accordingly, but I cannot find any documentation on how to do this. Any suggestions?
Just set the UIImagePickerController instance's allowsEditing to YES.
_imagePickerController = [[UIImagePickerController alloc] init];
...
_imagePickerController.delegate = self;
_imagePickerController.allowsEditing = YES;
The UIImagePickerController picker ONLY performs 320x320 cropping.
Try using this: https://github.com/gekitz/GKImagePicker (GKImagePicker)
Sample Code:
self.imagePicker = [[GKImagePicker alloc] init];
self.imagePicker.cropSize = CGSizeMake(320, 90);
self.imagePicker.delegate = self;
[self presentModalViewController:self.imagePicker.imagePickerController animated:YES];
I am using the IOS standard image cropping functionality (move and scale) to crop my image before submitting it to the server.
However, I realize that the cropping provided has a square ratio (see screenshot below)
Snippet of the code is as follows:
//set up image picker
self.imgPicker = [[[UIImagePickerController alloc] init]autorelease];
self.imgPicker.allowsEditing = YES;
self.imgPicker.delegate = self;
//Trigger get photo from library function
self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:self.imgPicker animated:YES];
How can allow 'move and scale' editing and at the same time allow the user to do cropping WITHOUT the square ratio restriction?
I think you need change self.imgPicker.allowsEditing = YES; to self.imgPicker.allowsEditing = NO;
This library can help you.
https://github.com/gekitz/GKImagePicker
It supports custom cropping and it's easy to integrate with the native picker if needed.
I think , this will serve your purpose . You can change the constraints as you want
https://github.com/kishikawakatsumi/PEPhotoCropEditor?source=cc