Skip to content

Instantly share code, notes, and snippets.

@hbridge
Created May 6, 2014 23:16
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 hbridge/42de971eba5bbc7f9bf4 to your computer and use it in GitHub Desktop.
Save hbridge/42de971eba5bbc7f9bf4 to your computer and use it in GitHub Desktop.
//1
NSDictionary *imageOptions =
@{
(NSString *)kCGImageSourceCreateThumbnailFromImageAlways : @YES,
(NSString *)kCGImageSourceThumbnailMaxPixelSize : [NSNumber numberWithUnsignedInteger:size],
(NSString *)kCGImageSourceCreateThumbnailWithTransform : @YES,
};
CGImageSourceRef src = CGImageSourceCreateWithURL((__bridge CFURLRef)asset.defaultRepresentation.url,
nil);
CGImageRef thumbnail = CGImageSourceCreateThumbnailAtIndex(src, 0, (__bridge CFDictionaryRef)imageOptions);
UIImage *image = [UIImage imageWithCGImage:thumbnail];
CGImageRelease(thumbnail);
CFRelease(src);
return image;
//2
NSDictionary *imageOptions =
@{
(NSString *)kCGImageSourceCreateThumbnailFromImageAlways : @YES,
(NSString *)kCGImageSourceThumbnailMaxPixelSize : [NSNumber numberWithUnsignedInteger:size],
(NSString *)kCGImageSourceCreateThumbnailWithTransform : @YES,
};
CGImageSourceRef src = CGImageSourceCreateWithURL((__bridge CFURLRef)asset.defaultRepresentation.url,
(__bridge CFDictionaryRef)imageOptions);
CGImageRef thumbnail = CGImageSourceCreateThumbnailAtIndex(src, 0, (__bridge CFDictionaryRef)imageOptions);
UIImage *image = [UIImage imageWithCGImage:thumbnail];
CGImageRelease(thumbnail);
CFRelease(src);
return image;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment