Reputation: 3745
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];
}
Upvotes: 1
Views: 62
Reputation: 3754
simple check for
if(image.size.height>=250&&image.size.width>=250)
{
NSLog(@"Convert it");
}
else
{
//alertview
}
Upvotes: 1
Reputation: 31339
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.
Upvotes: 1