Skip to content

Instantly share code, notes, and snippets.

@rais38
Last active December 12, 2015 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rais38/4690587 to your computer and use it in GitHub Desktop.
Save rais38/4690587 to your computer and use it in GitHub Desktop.
Resize UIImage
/**
@see http://stackoverflow.com/questions/3889687/how-to-compress-an-image-taken-by-the-camera-in-iphone-sdk
UIImage *image = [self scaleImage:myImage toSize:CGSizeMake(320.0,480.0)];
*/
-(UIImage *)scaleImage:(UIImage *)image toSize:(CGSize)newSize {
UIGraphicsBeginImageContext(newSize);
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment