如何在iPhone中验证imagesize?
我正在做iPhone应用程序。在这种情况下,我将图像转换为base64字符串。但是,我的问题是,在转换为base64字符串之前,我想验证图像大小,就像在图像大小250x250以下一样,我想将alertview else放入,如果iAge包含的图像超过250x250或euqal的大小相同,那么我只需要将图像作为base64字符串发送到服务器。请给我你宝贵的建议。提前感谢!我在做下面的代码如何在iPhone中验证imagesize?,iphone,image,image-size,validating,Iphone,Image,Image Size,Validating,我正在做iPhone应用程序。在这种情况下,我将图像转换为base64字符串。但是,我的问题是,在转换为base64字符串之前,我想验证图像大小,就像在图像大小250x250以下一样,我想将alertview else放入,如果iAge包含的图像超过250x250或euqal的大小相同,那么我只需要将图像作为base64字符串发送到服务器。请给我你宝贵的建议。提前感谢!我在做下面的代码 for(int img_pos=0;img_pos<[uploadPhotosArray count];
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];
}
for(int img\u pos=0;img\u pos您可以检查size属性以实现此目的
CGFloat width = conversionImage.size.width;
CGFloat height = conversionImage.size.height;
您可以通过scale
属性找到DPI(分辨率/比例)。简单检查
if(image.size.height>=250&&image.size.width>=250)
{
NSLog(@"Convert it");
}
else
{
//alertview
}