cloudinary / cloudinary_ios

Cloudinary iOS SDK
MIT License
165 stars 106 forks source link

Set max resolution when uploading? #16

Closed xaxist closed 9 years ago

xaxist commented 9 years ago

Hello,

I just tried my hands on the iOS SDK and was able to successfully upload an image to the Cloudinary platform. I used the image picker code and grabbed a high resolution image (3000x3000) pixels from iOS Photo Library, but the image uploaded was just about 640x640 pixels. How do I maintain the original image resolution while uploading.

Following is the iOS code


NSData *imageData = UIImageJPEGRepresentation(image, 1.0);

// Init Cloudinary Account
CLCloudinary *cloudinary = [[CLCloudinary alloc] initWithUrl: @"cloudinary://122323423424:GH67868HKJHKJkjhkjh@ahsgdfahsg"];

CLUploader* uploader = [[CLUploader alloc] init:cloudinary delegate:self];

[uploader upload:imageData
         options:@{}
        withCompletion:^(NSDictionary *successResult,
        NSString *errorResult,
        NSInteger code,
        id context)
{
    if (successResult)
    {
        NSString* publicId = [successResult valueForKey:@"public_id"];
        NSLog(@"Block upload success. Public ID=%@, Full result=%@", publicId, successResult);
    }
    else
    {
        NSLog(@"Block upload error: %@, %d", errorResult, code);

    }
}
andProgress:^(NSInteger bytesWritten, NSInteger totalBytesWritten, NSInteger totalBytesExpectedToWrite, id context)
{
    NSLog(@"Block upload progress: %d/%d (+%d)", totalBytesWritten, totalBytesExpectedToWrite, bytesWritten);
}];

Thanks in advance.

xaxist commented 9 years ago

Changing the code as follows did the trick and now I am able to upload larger resolution images.

pickerController.allowsEditing = NO;

I didn't knew about the limitations set by Apple when using the UIImagePickerController with editing allowed.