I am getting the following error running my app on a device (I'm not getting it running in the simulator):
CGImageCreateWithImageProvider`: invalid image size: 180 x 180.
- (IBAction)choosePic:(id)sender {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
self.imageOne = [[UIImagePickerController alloc] init];
self.imageOne.sourceType = UIImagePickerControllerSourceTypeCamera;
self.imageOne.delegate = self;
}
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
self.imageOne = [[UIImagePickerController alloc] init];
self.imageOne.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
self.imageOne.delegate = self;
}
[self presentViewController:self.imageOne animated:YES completion:nil];
}
As per the answer
this error can be of lower iOS version devices. As some iOS versions don't support resizing images. And also may be the problem of JPG image. Try with PNG image.
Related
This is my code to present the UIImagePickerController:
UIImagePickerController *imagepicker = [[UIImagePickerController alloc] init];
imagepicker.delegate = self;
imagepicker.view.backgroundColor = [UIColor orangeColor];
UIImagePickerControllerSourceType sourcheType = UIImagePickerControllerSourceTypePhotoLibrary;
imagepicker.sourceType = sourcheType;
imagepicker.allowsEditing = YES;
[self presentViewController:imagepicker animated:YES completion:nil];
This is the image where the error occurred
This is a normal picture
This happens on one iPad (iOS 11.1.2), but it works fine on the other (iOS 8.4.1). I tried the changes, but none seemed to work.
Im using tesseract OCR and it only reads 300 dpi images, when i take photos using UIImage picker controller camera the images are in 72 dpi how can i take images in 300 dpi like the stock app in iOS?
I'm using Tesseract on an iPad with iOS7 and the following code successfully presents the UIImagePickerController and I get an image back that I can readily OCR with Tesseract:
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
iosPicker = [[UIImagePickerController alloc] init];
iosPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
iosPicker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeImage, nil];
iosPicker.allowsEditing = NO;
iosPicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
iosPicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
iosPicker.modalPresentationStyle = UIModalPresentationFullScreen;
iosPicker.delegate = self;
[self presentViewController:iosPicker animated:YES completion:^{}];
}
Side note: iosPicker is an instance variable defined in the interface for the view controller.
I used a very popular code to capture photo with iPad
-(void)presentImagePicker:(UIImagePickerControllerSourceType)source sender:(UIButton *)sender
{
if (!self.popOver && [UIImagePickerController isSourceTypeAvailable:source])
{
NSArray *availableMedia = [UIImagePickerController availableMediaTypesForSourceType:source];
if ([availableMedia containsObject:(NSString*)kUTTypeImage])
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = source;
picker.mediaTypes = #[(NSString*)kUTTypeImage];
picker.allowsEditing = YES;
if (source != UIImagePickerControllerSourceTypeCamera &&
UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
self.popOver = [[UIPopoverController alloc] initWithContentViewController:picker];
[self.popOver presentPopoverFromRect:sender.bounds
inView:sender
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
self.popOver.delegate = self;
}
else
{
[self presentViewController:picker animated:YES completion:nil];
}
}
}
}
The problem is that when the picker shows up, the cropping-size of the capture image is different from the size of the iPad (full screen). It is like a box centered in the screen.
When I take the picture in portrait mode, the captured image is not the portrait image, but something different in size.
My application can run only in landscape mode: is that the problem?
The solution is here
GKImage picker
a custom picker, very very useful.
I want to crop a photo that is taken in the app and then save. I am using the GKImagePicker so that I can do this but if I use the code below even though I push the take photo button in my app it shows me the photo library which I pick to crop. I do not want to do this and just want to crop my photo which I have taken in the app.
- (IBAction)takePhoto:(UIButton *)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
self.imagePicker = [[GKImagePicker alloc] init];
self.imagePicker.cropSize = CGSizeMake(320, 320);
self.imagePicker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:self.imagePicker.imagePickerController animated:YES];
[self presentViewController:picker animated:YES completion:NULL];
}
Remove the last line in your code:
[self presentViewController:picker animated:YES completion:NULL];// remove
and give it a try ;)
You can also check this.
I am showing the camera in a popover (on an iPad - the iPad app is locked to Lanscape Left) and the preview is in Portrait and the wrong scale. The code is below - I have worked out the rotation and added it, but the preview size is the too thin now.
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.videoQuality = UIImagePickerControllerQualityTypeMedium;
imagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
CGAffineTransform transformRotation = CGAffineTransformMakeRotation(270 * M_PI/180);
imagePicker.cameraViewTransform = transformRotation;
}
else
{
NSLog(#"Camera not available. Using photo library");
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
imagePicker.delegate = self;
_photoPopover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[_photoPopover presentPopoverFromRect:view.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
Turns out to be an issue with the way iOS 6.0 deals with rotation - its fixed in 6.1
I think this is the solution for ur question so u can follow the code as per this link provided below.
UIImagePickerController in Landscape
It will helps u a lot.Enjoy the coding.