Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to reduce the UIImage size...?

I am having the images of size 1200x1200.(getting from server).how can i reduce it to 800x800(without using "Preview").because of the large image size , my app getting crashed..pls help me to solve this...thanks in advance.

like image 249
Madhumitha Avatar asked Feb 16 '11 05:02

Madhumitha


1 Answers

            UIImage *image = [actualImage you want to resize];
            UIImage *tempImage = nil;
            CGSize targetSize = CGSizeMake(196,110);
            UIGraphicsBeginImageContext(targetSize);

            CGRect thumbnailRect = CGRectMake(0, 0, 0, 0);
            thumbnailRect.origin = CGPointMake(0.0,0.0);
            thumbnailRect.size.width  = targetSize.width;
            thumbnailRect.size.height = targetSize.height;

            [image drawInRect:thumbnailRect];

            tempImage = UIGraphicsGetImageFromCurrentImageContext();

            UIGraphicsEndImageContext();

You can use this tempImage , it will be resized Image

Hope, it helps !

like image 61
Swastik Avatar answered Nov 14 '22 23:11

Swastik