0

After trying I was able to upload an image taken from the camera to my webserver.

But what I do no understand is why the image quality is crappy, low resolution, very few colors. Is there a way to get a better quality ?

here is my code :

NSURL *url = [NSURL URLWithString:@"http://localhost"];

    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];

    NSData *imageData = UIImageJPEGRepresentation(image, 0.9);

    NSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST" path:@"/upload.php" parameters:nil constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) {
        [formData appendPartWithFileData:imageData name:@"file" fileName:@"temp.jpeg" mimeType:@"image/jpeg"];
    }];

    AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];

    [operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
        NSLog(@"Sent %lld of %lld bytes", totalBytesWritten, totalBytesExpectedToWrite);
    }];

    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject)
    {
        NSString *response = [operation responseString];
        NSLog(@"response: [%@]",response);
        //[MBProgressHUD hideHUDForView:self.view animated:YES];
    }
    failure:^(AFHTTPRequestOperation *operation, NSError *error)
    {
        //[MBProgressHUD hideHUDForView:self.view animated:YES];
        if([operation.response statusCode] == 403)
        {
            NSLog(@"Upload Failed");
            return;
        }
        NSLog(@"error: %@", [operation error]);

    }];


    [operation start];

thanks Regis

user1961175
  • 19
  • 1
  • 4
  • You are going to need to do some comparisons with your original image to see where the quality drop is happening. How does the UIImageJPEGRepresentation compare with the original UIImage? How does the version on the server compare with the UIImageJPEGRepresentation? As well as a visual compare, look at their pixel dimensions and file sizes. – foundry Jan 22 '13 at 23:45

1 Answers1

0

Sorry guys in order to work on my webserver I use realVnc. The set up of RealVnc was set to low resolution !!! I did change setup to have a better resolution and now the problem is solved!

user1961175
  • 19
  • 1
  • 4