0

Do you have anyway to resize image from camera to small size. I would like to resize image to 612 * 612 with disk size is less than 100KB. This will help me to show image on application faster.

Any advise ?

Thuong Tran
  • 139
  • 1
  • 3
  • 11

2 Answers2

1

Look at this post for help:

The simplest way to resize an UIImage?

and check out Apple's documentation on UIImage

http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIImage_Class/Reference/Reference.html

Community
  • 1
  • 1
Omer Janjua
  • 622
  • 1
  • 7
  • 18
0

Try with this:

-(UIImage *)imageWithImage:(UIImage *)imageToCompress scaledToSize:(CGSize)newSize {

    UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0);
    [imageToCompress drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newImage;
}

Give your file name istead of getPath & call the above:

UIImage *img = [UIImage imageWithContentsOfFile:getPath];
UIImage *imageToPass = [self imageWithImage:img scaledToSize:CGSizeMake(612.0, 612.0)];
Vishal
  • 8,246
  • 6
  • 37
  • 52
  • This [self imageWithImage:img scaledToSize:CGSizeMake(612.0, 612.0)] line will automatically call above method & resize image... – Vishal May 30 '13 at 10:33
  • how is about image disk size ? it is less than 100KB with dimension 612 ? – Thuong Tran May 30 '13 at 10:46
  • it is so big, more than 800KB, it's loaded very slowly. Instagram can do this. I used Instagram app to take a picture, then share it on Facebook or Twitter, then I downloaded this image and checked its size. it's 72KB with that dimension. – Thuong Tran May 30 '13 at 10:57