Here is a screen a shot of the build settings I used to get it work. I'm on a MacPro running 10.6
BOOL maxPixelSizeByWidth = TRUE;
if (source != nil) {
int maxPixelSize;
if (_resizeWidth == -1 && _resizeHeight == -1) {
maxPixelSize = -1;
}
else if (_resizeWidth > _resizeHeight) {
maxPixelSize = _resizeWidth;
}
else {
// set it to false
maxPixelSizeByWidth = FALSE;
maxPixelSize = _resizeHeight;
}
CGImageRef originalImage;
NSMutableDictionary *thumbnailOpts = [NSMutableDictionary dictionary];
[thumbnailOpts setObject:(id)kCFBooleanTrue forKey:(id)kCGImageSourceCreateThumbnailWithTransform];
[thumbnailOpts setObject:(id)kCFBooleanTrue forKey:(id)kCGImageSourceCreateThumbnailFromImageAlways];
if (_dpi != -1) {
NSNumber *dpiNumber = [NSNumber numberWithInt:_dpi];
[thumbnailOpts setObject:dpiNumber forKey:(id)kCGImagePropertyDPIWidth];
[thumbnailOpts setObject:dpiNumber forKey:(id)kCGImagePropertyDPIHeight];
}
if (maxPixelSize != -1) {
if (! maxPixelSizeByWidth) {
// logic used to calculate the actual max pixel size.
originalImage = CGImageSourceCreateThumbnailAtIndex(source, 0, (CFDictionaryRef)thumbnailOpts);
NSInteger oWidth = CGImageGetWidth(originalImage);
NSInteger oHeight = CGImageGetHeight(originalImage);
if (oWidth > oHeight) {
maxPixelSize = (oWidth * maxPixelSize) / oHeight;
}
}
[thumbnailOpts setObject:[NSNumber numberWithInt:maxPixelSize] forKey:(id)kCGImageSourceThumbnailMaxPixelSize];
originalImage = CGImageSourceCreateThumbnailAtIndex(source, 0, (CFDictionaryRef)thumbnailOpts);
}