When I do an NSLog on the size of the image after putting it into a UIImage, it comes out at the expected size. When I try this with CGImageSource however, I get an image twice the size as I was expecting. This is the code I'm using for that:
NSString *fullPath = [self fullPathForThumbnail];
NSURL *imageFileURL = [NSURL fileURLWithPath:fullPath];
CGImageSourceRef imageSource = CGImageSourceCreateWithURL((__bridge CFURLRef)imageFileURL, NULL);
if (imageSource == NULL) {
// Error loading image
return NO;
}
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO], (NSString *)kCGImageSourceShouldCache,
nil];
CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, (__bridge CFDictionaryRef)options);
CGSize originalSize;
if (imageProperties) {
NSNumber *width = (NSNumber *)CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelWidth);
NSNumber *height = (NSNumber *)CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelHeight);
originalSize = CGSizeMake(width.floatValue, height.floatValue);
CFRelease(imageProperties);
}
This only happens on retina images; non-retina images seem to be the correct size.