How to Create Thumbnail of UIImage – XCode iOS

Use the following Code to Create Thumbnail of UIImage Object –

1
2
3
4
5
6
UIImage *originalImage = ...;
CGSize destinationSize = ...;
UIGraphicsBeginImageContext(destinationSize);
[originalImage drawInRect:CGRectMake(0,0,destinationSize.width,destinationSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

Replace the originalImage object with your original image of which you want to create the thumbnail. The new version of the same image ie. the thumbnail will be the newImage object. The original image will not be modified.

You can now save the thumbnail image to documents directory of the iOS Device. Check the following article Save and Load UIImage in Documents Directory on iPhone.

Namit Gupta

iOS Consultant at @RapidCircle. Passionate about Mobile Apps. Loves to Design. You can reach him on his social profiles below.

Leave a Reply