Re: Getting image info without loading entire image
Re: Getting image info without loading entire image
- Subject: Re: Getting image info without loading entire image
- From: Ken Tozier <email@hidden>
- Date: Fri, 19 Jan 2007 15:55:32 -0500
On Jan 19, 2007, at 2:55 PM, Kaelin Colclasure wrote:
If you are not seeing the full set of image attributes, then for
some reason or another the image you are trying to work with has
not been imported by Spotlight. (This could be because the
filesystem where the image is stored is not indexed, or because
it's in a filtered location... If you send a sample of the mdls
command and output I might be able to suggest why.)
I mentioned it in the initial post, but neglected to in the followup,
but what I need to do is get attributes from images on a non-indexed
Windows box. I have the folder scanning code working nicely but
wanted to get the image height/width as quickly and with as little
overhead as possible so I can store this info in a database. Other
parts of my application use this image info to exactly size picture
boxes in QuarkXPress before importing the image, saves several steps.
I can get this info by loading the image like this
NSImageRep *img = [NSImageRep imageRepWithContentsOfFile: inPath];
if (img != nil)
{
width = [NSNumber numberWithInt: [img pixelsWide]],
height = [NSNumber numberWithFloat: [img pixelsHigh]];
}
But I'm dealing with thousands of images and the folder scanner
really bogs down because it has to load every one into memory.
Gregory Weston's suggestion of directly loading and using the
"Image.mdimporter" plugin sounds like a promising possibility but
unfortunately, it's "GetMetadataForFile" function seems to have a
custom name as the following fails
typedef Boolean (*GET_METADATA_FOR_FILE)(void *thisInterface,
CFMutableDictionaryRef attributes,
CFStringRef contentTypeUTI,
CFStringRef pathToFile);
NSURL *bundleURL = [NSURL fileURLWithPath: @"/System/Library/
Spotlight/Image.mdimporter"];
CFBundleRef bundleRef = CFBundleCreate(kCFAllocatorDefault,
(CFURLRef) bundleURL);
GET_METADATA_FOR_FILE getter = CFBundleGetFunctionPointerForName
(bundleRef, CFSTR("GetMetadataForFile"));
if (getter == NULL)
NSLog(@"GetMetadataForFile failed");
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden