ios 判断相册文件图片大小的方法

时间:2023-03-08 20:54:49

ALAssetsLibrary* alLibrary = [[ALAssetsLibrary alloc] init];

[alLibrary assetForURL:[info objectForKey:UIImagePickerControllerReferenceURL] resultBlock:^(ALAsset *asset)

{

ALAssetRepresentation *representation = [asset defaultRepresentation];

if ([representation size] > 1000*1000*2)

{

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"图片超出了2M,请重新选择" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];

alert.tag = KIMAGE_EXCEED_TAG;

[alert show];

return;

}

else

{

UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

UIImage *uploadImage = [FMUImage imageByScalingAndCroppingForSize:CGSizeMake(800, 600) SourceImage:image CropType:FMUIMAGE_SCALE_TYPE_FITMIN];

//发起上传网络请求

self.temper = [gNetworkManager uploadHousePic:uploadImage delegate:self]

[self dismissModalViewControllerAnimated:YES];

}

}

failureBlock:^(NSError *error)

{

}];