views:

347

answers:

0

Hi,

I want to create the thumbnail using the CG. It creates the thumbnails.

Here i want to have the thumbnail with the size 1024 (with aspect ratio.) Is it possible to get the desired size thumbnail directly from the CG?

In the options dictionary i can pass the max size of the thumnail can be created, but is there any way to have min size for the same..?

 NSURL * url = [NSURL fileURLWithPath:inPath];
 CGImageSourceRef source = CGImageSourceCreateWithURL((CFURLRef)url, NULL);
 CGImageRef image=nil;
 if (source)
 {
  NSDictionary* thumbOpts = [NSDictionary dictionaryWithObjectsAndKeys:
           (id) kCFBooleanTrue, (id)kCGImageSourceCreateThumbnailWithTransform, 
           (id)kCFBooleanTrue, (id)kCGImageSourceCreateThumbnailFromImageIfAbsent,
           [NSNumber numberWithInt:2048],  kCGImageSourceThumbnailMaxPixelSize,

           nil];

  image = CGImageSourceCreateThumbnailAtIndex(source, 0, (CFDictionaryRef)thumbOpts);   

  NSLog(@"image width = %d %d", CGImageGetWidth(image), CGImageGetHeight(image));
  CFRelease(source);
 }