im trying to resize a thumbnail from a video captured using a UIImagePickerController using MPMoviePlayerController. here is what im using:
self.moviePlayer.contentURL = [info objectForKey:UIImagePickerControllerMediaURL];
UIImage *thumbnail = [self.moviePlayer thumbnailImageAtTime:1 timeOption:MPMovieTimeOptionNearestKeyFrame];
self.thumbnailImage = [self resizeImage:thumbnail toWidth:75.0 andHeight:75.0];
and here is my resize method:
- (UIImage *)resizeImage:(UIImage *)image toWidth:(float)width andHeight:(float)height {
CGSize newSize = CGSizeMake(width, height);
CGRect newRect = CGRectMake(0, 0, width, height);
UIGraphicsBeginImageContext(newSize);
[self.image drawInRect:newRect];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resizedImage;
}
the resize method works for photos captured in the imagePicker, but for some reason the image is blank when I use it on the video thumbnail. if I dont resize it it appears fine but for some reason resizing it messes it up. im using ios7 and testing on an iPhone 5s
UIGraphicsBeginImageContext(newSize);
[image drawInRect:newRect];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
I was using [self.image drawInRect] instead of [image drawInRect] stupid mistake. wow.