• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting image info without loading entire image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting image info without loading entire image


  • Subject: Re: Getting image info without loading entire image
  • From: Kaelin Colclasure <email@hidden>
  • Date: Fri, 19 Jan 2007 11:55:39 -0800


On Jan 19, 2007, at 11:20 AM, Ken Tozier wrote:


On Jan 19, 2007, at 1:56 PM, Kaelin Colclasure wrote:


Hi Ken,

I missed the earlier messages in this thread, but... is there a reason why you're trying to load and run the importer instead of simply asking Spotlight for the attributes directly?


The initial question dealt with quickly fetching the width and height of images and Gregory suggested loading the Image.md importer.



MDItemRef item = MDItemCreate(kCFAllocatorDefault, inPath);
if (item != NULL) {
CFArrayRef attributeNames = MDItemCopyAttributeNames(item);
CFDictionaryRef attributes = MDItemCopyAttributes(item, attributeNames);
// ...
}



I just tried that and it sort of works, but unfortunately it doesn't expose the image width and height, just the generic file properties (name, size, mode date etc)


I notice in Spotlight that image width, height etc info is available. Any idea how to get at this more specific image info?


Try this from the command line (substituting the path to an image file of your choice):

[kaelin@aoide kaelin]$ mdls ~/Pictures/DSC_0231.jpg
/Volumes/Local/Users/kaelin/Pictures/DSC_0231.jpg -------------
kMDItemAttributeChangeDate = 2006-04-18 16:49:52 -0700
kMDItemBitsPerSample = 32
kMDItemColorSpace = "RGB"
kMDItemContentCreationDate = 2005-05-16 09:54:08 -0700
kMDItemContentModificationDate = 2005-05-16 09:54:08 -0700
kMDItemContentType = "public.jpeg"
kMDItemContentTypeTree = ("public.jpeg", "public.image", "public.data", "public.item", "public.content")
kMDItemDisplayName = "DSC_0231.jpg"
kMDItemFSContentChangeDate = 2005-05-16 09:54:08 -0700
kMDItemFSCreationDate = 2005-05-16 09:54:08 -0700
kMDItemFSCreatorCode = 0
kMDItemFSFinderFlags = 0
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSLabel = 0
kMDItemFSName = "DSC_0231.jpg"
kMDItemFSNodeCount = 0
kMDItemFSOwnerGroupID = 501
kMDItemFSOwnerUserID = 501
kMDItemFSSize = 207883
kMDItemFSTypeCode = 0
kMDItemHasAlphaChannel = 0
kMDItemID = 450643
kMDItemKind = "JPEG Image"
kMDItemLastUsedDate = 2005-05-16 09:54:08 -0700
kMDItemPixelHeight = 3008
kMDItemPixelWidth = 2000
kMDItemUsedDates = (2005-05-16 09:54:08 -0700)



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.)


Once you're working with an imported image and you know exactly the attributes you are interested in, the above code snippet can be even further abbreviated to:

MDItemRef item = MDItemCreate(kCFAllocatorDefault, inPath);
if (item != NULL) {
CFDictionaryRef attributes = MDItemCopyAttributeList(item, kMDItemPixelHeight, kMDItemPixelWidth, NULL);
// ...
}


-- Kaelin



_______________________________________________

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


  • Follow-Ups:
    • Re: Getting image info without loading entire image
      • From: Ken Tozier <email@hidden>
References: 
 >Re: Getting image info without loading entire image (From: Ken Tozier <email@hidden>)
 >Re: Getting image info without loading entire image (From: Kaelin Colclasure <email@hidden>)
 >Re: Getting image info without loading entire image (From: Ken Tozier <email@hidden>)

  • Prev by Date: Re: Getting image info without loading entire image
  • Next by Date: notification on screensaver unlock ?
  • Previous by thread: Re: Getting image info without loading entire image
  • Next by thread: Re: Getting image info without loading entire image
  • Index(es):
    • Date
    • Thread