• 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: Read jpeg comments from file?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Read jpeg comments from file?


  • Subject: Re: Read jpeg comments from file?
  • From: Trygve Inda <email@hidden>
  • Date: Thu, 03 Apr 2008 09:13:13 +0000
  • Thread-topic: Read jpeg comments from file?

> If you just need to display the image, use an NSImage
> (initWithContentsOfFile).
> If you need a greater control over metadata, use the ImageIO API
> (search CGImageSource in doc and sample codes).

This doesn't work:

CGImageSourceRef source = CGImageSourceCreateWithURL ((CFURLRef) [NSURL
fileURLWithPath:path], NULL);

NSDictionary*    metadata = (NSDictionary
*)CGImageSourceCopyPropertiesAtIndex(source,0,NULL);

I get a dict with: ColorModel, Depth, DensityUnit etc. but no key with the
user text.

This works and retrieves the user text that was embedded in the image). Is
there a more Cocoa-way to do this ather than having to use QuickTime and
FSSpecs?

GraphicsImportComponent  tGIC;
ComponentResult          result;
UserData                 myUD;
Handle                   dataHandle;
CFStringRef              cfString = nil;
FSRef                    theFSRef;
FSSpec                   theFSSpec;
OSErr                    err;


CFURLGetFSRef ((CFURLRef) [NSURL fileURLWithPath:path], &theFSRef);
err = FSGetCatalogInfo (&theFSRef, kFSCatInfoParentDirID, NULL, NULL,
&theFSSpec, NULL);

result = GetGraphicsImporterForFile (&theFSSpec, &tGIC);
if (result == noErr)
{
 err = NewUserData(&myUD);
 if (!err)
 {
  result = GraphicsImportGetMetaData (tGIC, myUD);
  if (result == noErr)
  {
    dataHandle = NewHandle (0);
    if (dataHandle)
    {
     err = GetUserDataText (myUD, dataHandle, kUserDataTextComment, 1, 0);
     if (!err)
     {
       HLock (dataHandle);
       cfString = CFStringCreateWithBytes (kCFAllocatorDefault, (UInt8 *)
(*dataHandle), GetHandleSize(dataHandle), kCFStringEncodingMacRoman, false);
                }
            }
        }
    }
 }
}


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: Read jpeg comments from file?
      • From: Steve Christensen <email@hidden>
References: 
 >Re: Read jpeg comments from file? (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Re: activate my application while dragging on other application window
  • Next by Date: Re: How to store NSRect as Core Data attribute?
  • Previous by thread: Re: Read jpeg comments from file?
  • Next by thread: Re: Read jpeg comments from file?
  • Index(es):
    • Date
    • Thread