문제

I am doing iPhone Application. In that i am converting the image into base64 string. But, my issue is before converting into base64 string, i want to validate image size as if below image size 250x250, i want to put alertview else if imaage contains more than 250x250 or euqal to same size then only i need to send image as base64 string to server. plase give me your valuable suggestion. Thanks in advanced! im doing below code

for(int img_pos=0;img_pos<[uploadPhotosArray count];img_pos++)
{
    [self startIndicator];
    conversionImage= [UIImage imageWithContentsOfFile:[uploadPhotosArray objectAtIndex:img_pos]];
    NSData *imageData = UIImageJPEGRepresentation(conversionImage,1.0);
    [Base64 initialize];
    NSString *uploadPhotoEncodedString = [Base64 encode:imageData];
    //NSLog(@"Byte Array %d : %@",img_pos,uploadPhotoEncodedString);
    [uploadPhotosByteArray addObject:uploadPhotoEncodedString];

}
도움이 되었습니까?

해결책

simple check for

if(image.size.height>=250&&image.size.width>=250)
{
     NSLog(@"Convert it");
}
else
{
   //alertview
}

다른 팁

You can check the size property to acheive this

CGFloat width = conversionImage.size.width;
CGFloat height = conversionImage.size.height;

You can find the DPI (resolution/scale) through the scale attribute.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top