Get metadata from NSImage
.........................................
LOG
- + (NSDictionary*) exif : (NSString*) file
- {
- NSDictionary* dic = nil;
- NSURL* url = [ NSURL fileURLWithPath : file ];
- if ( url )
- {
- CGImageSourceRef source = CGImageSourceCreateWithURL ( (CFURLRef) url, NULL);
- if ( NULL == source )
- {
- #ifdef _DEBUG
- CGImageSourceStatus status = CGImageSourceGetStatus ( source );
- NSLog ( @"Error: file name : %@ - Status: %d", file, status );
- #endif
- }
- else
- {
- CFDictionaryRef metadataRef =
- CGImageSourceCopyPropertiesAtIndex ( source, 0, NULL );
- if ( metadataRef )
- {
- NSDictionary* immutableMetadata = (NSDictionary *)metadataRef;
- if ( immutableMetadata )
- {
- dic =
- [ NSDictionary dictionaryWithDictionary : (NSDictionary *)metadataRef ];
- }
- CFRelease ( metadataRef );
- }
- CFRelease(source);
- source = nil;
- }
- }
- return dic;
- }
.........................................
- NSDictionary* dic = [ User_ImageLoader exif : filename ];
- if ( dic )
- {
- NSString* s = [ dic valueForKey : @"Orientation" ];
- NSLog(@"Image : %@ - orentation : %d", filename, [ s intValue ] );
- }
LOG
2011-07-21 00:09:44.579 test.app [12105:7f03] Image : /Users/alexey/Desktop/Works/EXIF Orientation Sample Images/7.jpg - orentation : 7
2011-07-21 00:09:45.908 test.app [12105:7f03] Image : /Users/alexey/Desktop/Works/EXIF Orientation Sample Images/8.jpg - orentation : 8
Create CGImageRef with EXIF Orientation
Create CGImageRef with EXIF Orientation