How to resize image programmatically in iPhone

H

Hello friends, many times we need to resize the UIImage runtime according to the need of application.  Here is the function which changes the size of the image and returns a new resized image

– (UIImage *)reSizeTheImage:(UIImage *)image convertToSize:(CGSize)size {

UIGraphicsBeginImageContext(size);

[image drawInRect:CGRectMake(0, 0, size.width, size.height)];

UIImage *destImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return destImage;

}

 

You need to provide the size in which you want to resize the image.

That’s it. Just 5 lines makes the job easy…Isn’t it?

 

About the author

minakshi.bhosale
By minakshi.bhosale

Category