2017-12-22 40 views
-1

私は各画像が最大3MBのはずですが、複数の画像をサーバーに送る必要があります。どのように画像のサイズを3Mbに制限するか、3b以上の場合は3mb.someにサイズ変更する方法でこの問題を解決してください。私は画像の複数の選択で行った3MbにuIImageのサイズを変更するには

答えて

-1
UIImage *img = [UIImage imageWithData:imageData]; 
    CGFloat imageWidth = img.size.width; 
    CGFloat imageHeight = img.size.height; 

    if(imageWidth > 10000 || imageHeight > 10000) { 
    UIGraphicsBeginImageContext(CGSizeMake(imageWidth/10, imageHeight/10)); 
    [image drawInRect:CGRectMake(0,0,imageWidth/10,imageHeight/10)]; 
    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    imageData = UIImageJPEGRepresentation(img, 1); 
    } 

10と10000はあなたの要件に応じて変更されます。

関連する問題