Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem with CGImageDestination and file naming
    primarykey
    data
    text
    <p>I am capturing images from the camera, using AVCapture as I have need of speed and the standard kit stuff is way too slow. I have problem whereby the file that is being output (an animated GIF) is having it's file name mangles by the CGImageDestination functions...</p> <p>When I output the NSURL (cast to a CFURLRef) to the log I get the path/filename I intended:</p> <pre><code>2011-09-04 20:40:25.914 Mover[3558:707] Path as string:.../Documents/91B2C5E8-F925-47F3-B539-15185F640828-3558-000003327A227485.gif </code></pre> <p>However, once the file is created and saved it actually lists the filename as this:</p> <pre><code>2011-09-04 20:40:25.960 Mover[3558:707] file: .91B2C5E8-F925-47F3-B539-15185F640828-3558-000003327A227485.gif-TtNT </code></pre> <p>See the difference? the period at the start and the 4 character suffix? Whats really wierd is that it doesn't <em>always</em> do it, about 40% of the time it works OK. However it's preventing the code working further down the line where I'm listing them with previews in a table view.</p> <p>Does anyone know why and how to stop it doing this?</p> <p>Here's the code:</p> <pre><code>- (void)exportAnimatedGif{ NSString *guidPath = [[NSProcessInfo processInfo] globallyUniqueString]; NSString *tmpPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:guidPath]; NSString *path = [tmpPath stringByAppendingPathExtension:@"gif"]; NSLog(@"Path as string:%@", path); CGImageDestinationRef destination = CGImageDestinationCreateWithURL((CFURLRef)[NSURL fileURLWithPath:path], kUTTypeGIF, [captureArray count], NULL); NSDictionary *frameProperties = [NSDictionary dictionaryWithObject:[NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:testDisplay3.displayValue] forKey:(NSString *)kCGImagePropertyGIFDelayTime] forKey:(NSString *)kCGImagePropertyGIFDictionary]; NSDictionary *gifProperties = [NSDictionary dictionaryWithObject: [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:2], (NSString *)kCGImagePropertyGIFLoopCount, [NSNumber numberWithFloat:testDisplay3.displayValue], (NSString*)kCGImagePropertyGIFDelayTime, [NSNumber numberWithFloat:testDisplay3.displayValue], (NSString*)kCGImagePropertyGIFUnclampedDelayTime, nil] forKey:(NSString *)kCGImagePropertyGIFDictionary]; for (int ii = 0; ii &lt; [captureArray count]; ii++) { UIImage *tmpImg = [[UIImage alloc] init]; tmpImg = [captureArray objectAtIndex:ii]; CGImageDestinationAddImage(destination, tmpImg.CGImage, (CFDictionaryRef)frameProperties); } CGImageDestinationSetProperties(destination, (CFDictionaryRef)gifProperties); CGImageDestinationFinalize(destination); CFRelease(destination); //TEST OUTPUT GENERATED FILES NSArray *contents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] error:nil]; for (int xx = 0; xx &lt; [contents count]; xx++) { NSLog(@"file: %@", [contents objectAtIndex:xx]); } //END TEST CODE [captureArray removeAllObjects]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload