2013-05-09 57 views
2

在我的應用程序中,如果用戶從相機膠捲中選擇圖像作爲compnay徽標使用(添加到最終pdf),它可以將附件中的文件大小從8mb(無圖像)在一些情況下爲29mb。這是一個問題,當用戶的郵件文件作爲其啤酒比大多數服務器將允許attachement尺寸優化從相機膠捲中選取的圖像以減小文件大小

- (IBAction)schemeLogoPressed:(id)sender { 
LogCmd(); 
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; 
    imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
    imagePicker.delegate = self; 
    imagePicker.allowsEditing = NO; 
    [self.editController presentModalViewController:imagePicker animated:YES]; 
    }  

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{ 
    DebugLog(@"info dict: %@", info); 
    [picker dismissModalViewControllerAnimated:YES]; 
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; 
    self.schemeLogo.backgroundColor = [UIColor whiteColor]; 
    self.schemeLogo.image = image; 
    NSData *imageData1 = UIImagePNGRepresentation(image); 
    NSString *path1 = [ICUtils pathForDocument:@"schemeLogo.png"]; 
    [imageData1 writeToFile:path1 atomically:NO]; 

有什麼我可以做優化攝取的圖像尺寸是多少?

回答

5

改變這一行:

NSData *imageData1 = UIImagePNGRepresentation(image); 

到:

NSData *imageData1 = UIImageJPEGRepresentation(image, 0.9f); 

第二參數(0.9浮動)是質量。數量更多,質量更高。從0.0到1.0

+0

究竟是我之後,簡單明瞭地解釋了謝謝,再加上1! – JSA986 2013-05-09 11:38:40

相關問題