CFHipsterRef Low-Level Programming on iOS & Mac OS X

Writing to a File

UIImage *image = ...;
NSURL *fileURL = [NSURL fileURLWithPath:@"/path/to/output.jpg"];
NSString *UTI = @"public.jpeg";
NSDictionary *options = @{
    (__bridge id)􏰀 kCGImageDestinationLossyCompressionQuality: @(0.75),
    (__bridge id)kCGImagePropertyOrientation: @(4), (__bridge id)kCGImagePropertyHasAlpha: @(NO)
    };

CGImageDestinationRef imageDestinationRef =
    CGImageDestinationCreateWithURL((__bridge CFURLRef)fileURL,
        (__bridge CFStringRef)UTI, 1, NULL);

CGImageDestinationAddImage(imageDestinationRef,[imageCGImage],(__bridge CFDictionaryRef)options);

CGImageDestinationFinalize(imageDestinationRef);
CFRelease(imageDestinationRef);