1

I'm trying to create an aspect ratio thumbnail from an ALAsset for pre iOS5 (the ALAssetDefaultRepresentation aspectRatioThumbnail wasn't implemented until ios5). I have the following code and it's giving me an error for some reason:

CGImageRef imref;
    NSURL* url = [self.photoAsset.defaultRepresentation url];
    NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
                       (id)kCFBooleanTrue, kCGImageSourceShouldAllowFloat,
                       (id)kCFBooleanTrue, kCGImageSourceCreateThumbnailWithTransform,
                       (id)kCFBooleanTrue, kCGImageSourceCreateThumbnailFromImageAlways,
                       [NSNumber numberWithInteger:1024], kCGImageSourceThumbnailMaxPixelSize, nil];
    CGImageSourceRef src = CGImageSourceCreateWithURL((CFURLRef)url, NULL);
    imref = CGImageSourceCreateThumbnailAtIndex(src, 0, (CFDictionaryRef) dictionary);

Specifically I'm getting:

ImageIO: <ERROR>  CGImageSourceCreateWithURL CFURLCreateDataAndPropertiesFromResource failed with error code -11.ImageIO: <ERROR>  CGImageSourceCreateThumbnailAtIndex image source parameter is nil

Anyone know what's going on?

1

1 Answer 1

1

The problem is with the url that you are passing to create 'src', check wether url is valid and there exists some image at this url.

1
  • I think the URL I'm retrieving isn't for the image, but for the asset itself. Any idea how to get the image URL?
    – Ser Pounce
    May 16, 2012 at 0:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.