Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ImageIO versus UIImageJPEGRepresentation
// UIImageJPEGRepresentation
NSData *data = UIImageJPEGRepresentation(tileImage, 0.71);
[data writeToURL:cacheURL atomically:YES];
// ImageIO
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/UTCoreTypes.h>
CGImageDestinationRef destination = CGImageDestinationCreateWithURL((CFURLRef)cacheURL, kUTTypeJPEG, 1, NULL);
NSDictionary *destOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:0.71] forKey:(NSString *)kCGImageDestinationLossyCompressionQuality];
CGImageDestinationAddImage(destination, [scaledTileImage CGImage], (CFDictionaryRef)destOptions);
CGImageDestinationFinalize(destination);
CFRelease(destination);
@jllubia
Copy link

jllubia commented Dec 11, 2012

UIImageJPEGRepresentation uses ImageIO underneath.

@shaneowens
Copy link

shaneowens commented Dec 18, 2013

Do you have any bench marks for memory usage and speed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment