1

In my iPhone app am uploading images to server and downloading and displaying. Since the image size is too big, am getting memory warning. Is there any better way to compress image size without losing quality while uploading? Please help!!!

user1645198
  • 95
  • 2
  • 9

2 Answers2

1

While going through Stackoverdflow following this link I find out following code

 + (UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize;
 {
    UIGraphicsBeginImageContext( newSize );
    [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return newImage;
 }
Community
  • 1
  • 1
Shashank Kulshrestha
  • 1,556
  • 17
  • 31
0

If you really need lossless, the best you can do is to encode your image as a PNG with UIImagePNGRepresentation. You can also resize the image before uploading.

Mike Weller
  • 45,401
  • 15
  • 131
  • 151