Re: Reading & writing Exif data with Cocoa
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