0
시도한 후 카메라에서 가져온 이미지를 웹 서버에 업로드 할 수있었습니다.UIImageJPEG 표현 및 엉성한 이미지
그러나 내가 이해할 수없는 것은 왜 이미지 품질이 엉터리이며, 해상도가 낮고, 색상이 거의없는 것입니다. 더 나은 품질을 얻을 수있는 방법이 있습니까? 내가위한 RealVNC를 사용하여 내 웹 서버에서 작동하기 위해
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];
감사 레지스
품질 저하가 발생한 곳을 확인하려면 원본 이미지와 비교해야 할 수도 있습니다. UIImageJPEGRepresentation은 원래 UIImage와 어떻게 비교됩니까? 서버의 버전은 UIImageJPEGRepresentation과 어떻게 비교됩니까? 비주얼 비교뿐 아니라 픽셀 크기와 파일 크기를 살펴보십시오. – foundry