2012-06-14 2 views
0

내 iPad 앱에서 여러 사진을 찍은 다음 모든 이미지를 압축하여 서버에 업로드 할 수 있습니다. 내가 직면하는 문제는 큰 크기의 이미지로 인해, zip 파일의 크기가 증가하고 업로드하는 동안 실패합니다. 이미지를 클릭 한 직후에 저품질 이미지를 어떻게 저장할 수 있습니까? 당신은 모든 이미지 배열에 집어 저장할 수iPad + 이미지 피커 품질을 낮게 설정하십시오.

-(UIImage *)resizeImage:(UIImage *)image width:(float)imgwidth height:(float)imgheight 
    { 
    CGSize imgSize; 
    imgSize.width= imgwidth; 
    imgSize.height= imgheight; 
    UIGraphicsBeginImageContext(imgSize); 
    [image drawInRect:CGRectMake(0,0,imgSize.width,imgSize.height)]; 
    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    return newImage; 
    } 

:

답변

1

이미지는 어느 정도 이미지의 크기를 줄이는 데 도움이됩니다 JPG format.This에 format.Convert PNG로 캡처됩니다.

또는 일부 다른 인자 여기

의해 화상 압축 코드이다

// 코드

if(imagesize>[MAX_SIZE_IMAGE intValue]){ 

    while (imagesize>[MAX_SIZE_IMAGE intValue]){ 

     NSData *data=UIImageJPEGRepresentation(Image, 0.1f); 

     imagesize=[data length]; 
    } 
} 

jpgImage =[UIImage imageWithData:data]; 

return jpgImage; 
어떤 값 MAX_SIZE_IMage 설정 여기

하고 감소까지 다음 0.1의 비율로 이미지를 압축 최대 이미지 크기보다 작은 크기로 조정하십시오.

0

기능은 이미지 크기를 조정합니다. 이제 크기로 압축 크기 조정 이미지를 만들기 전에 :

for(int i = 0; [array count]; i++) 
    { 
    // call resize function here 
    //Again store all resized image in another array Now u have all images in low quality for zip 
    } 
관련 문제