• 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: Reading & writing Exif data with Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading & writing Exif data with Cocoa


  • Subject: Re: Reading & writing Exif data with Cocoa
  • From: loïc ségalou <email@hidden>
  • Date: Wed, 6 Jul 2005 04:11:38 +0200

On 6 juil. 05, at 01:19, Ken Ferry wrote:

On 7/5/05, fp12 <email@hidden> wrote:


So, is it possible to get/set GPS info with the Cocoa API ?



The ImageIO framework has mechanisms for this. It isn't Cocoa, but it's easy to use from a Cocoa app.


This is working fine with the IPTC properties for example, but unfortunately, with the GPS metadata (kCGImagePropertyGPSDictionary) it seems to be "read only" properties :-( ... ( I didn't read any limitation about this on the documentation ).


Sample code :

#import <Foundation/Foundation.h>
#import <Quartz/Quartz.h>

int main (int argc, const char * argv[]) {

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    NSString * imagePath = @"myImage.jpg";

NSDictionary *gpsDatumDictionary = [NSDictionary dictionaryWithObject:@"WGS-84" forKey:(NSString *) kCGImagePropertyGPSMapDatum];
NSDictionary *newGPSProperties = [NSDictionary dictionaryWithObject:gpsDatumDictionary forKey:(NSString *) kCGImagePropertyGPSDictionary];
NSMutableData *newImageData = [[NSMutableData alloc] init];
CGImageSourceRef imageSource = CGImageSourceCreateWithURL ((CFURLRef)[NSURL fileURLWithPath:imagePath], nil);
CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((CFMutableDataRef)newImageData,
CGImageSourceGetType(imageSource),
1,
NULL);
CGImageDestinationAddImageFromSource(imageDestination,
imageSource,
0,
(CFDictionaryRef) newGPSProperties);


if (CGImageDestinationFinalize(imageDestination)) {
[newImageData writeToFile:@"newImageWithGPSInfo.jpg" atomically:NO];
}


    CFRelease(imageDestination);
    CFRelease(imageSource);
    [newImageData release];

    [pool release];
    return 0;
}

Has anyone else got a solution to this kind of problem and can point me to it before I fill a bug report ?

Thanks,

-- loïc _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Reading & writing Exif data with Cocoa (From: fp12 <email@hidden>)
 >Re: Reading & writing Exif data with Cocoa (From: Ken Ferry <email@hidden>)

  • Prev by Date: Re: How to use NSMenuItem setAlternate?
  • Next by Date: Re: Reading data from an NSTask [SOLVED]
  • Previous by thread: Re: Reading & writing Exif data with Cocoa
  • Next by thread: Re: Reading & writing Exif data with Cocoa
  • Index(es):
    • Date
    • Thread