I'm uploading an image taken on the iPhone(Converted to NSData) via FTP on an iOS application using https://github.com/lloydsargent/BlackRaccoon.
dataImage = UIImageJPEGRepresentation(image, 0.5);
The problem is that the image size is about 40mb and every time the app finish uploading, Xcode Crashes. How can I make the image smaller?
This method will allow you to resize an image in Objective-C programmatically.
+ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize {
UIGraphicsBeginImageContextWithOptions(newSize, YES, [UIScreen mainScreen].scale);
[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
Basically I recommend you resize the image and then upload it if the issue is the API you are using. That being said, using the NSURLConnection class methods, I have been able to upload files larger than 40mb. You can check out a post I just made out about how to use those methods to upload files with a PHP back-end here:
Strange issue while posting image from iPhone
Make sure to mark my answer as correct if it helps!