iphoneimageimage-sizevalidating

How to validate imagesize in iPhone?


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];

}

Solution

  • simple check for

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