16
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JPEGデータからexif情報を取得する方法

Last updated at Posted at 2013-05-26

とりあえず、stack over flow の情報を基に、exifデータを読み込む事が出来たので、一時的にメモ。
JPEGデータは compression quality のデータを読み込む必要があるため、URLをそのまま渡して、exifデータを読み込んだ方が早そう。後々、ImageIO, CoreLocationについても読み込んで追加する。

###ソースコード

#import "ViewController.h"
#import <ImageIO/ImageIO.h>
#import <CoreLocation/CoreLocation.h>

@interface ViewController ()
@end

@implementation ViewController
- (void)viewDidLoad
{
    [super viewDidLoad];

    NSString *imgPath = [NSString stringWithFormat:@"%@/exit_test.JPG", [[NSBundle mainBundle] resourcePath]];
    CGImageSourceRef source = CGImageSourceCreateWithURL((CFURLRef)CFBridgingRetain([NSURL fileURLWithPath:imgPath]), nil);
    
    NSDictionary *metadata = (NSDictionary *) CFBridgingRelease(CGImageSourceCopyPropertiesAtIndex(source, 0, NULL));
    
    //GPS Dictionary
    NSDictionary *GPSDictionary = [metadata objectForKey:(NSString *)kCGImagePropertyGPSDictionary];
}
@end

取得したデータ

2013-05-27 01:33:51.685 test_exif[6363:c07] {
Altitude = "103.0715";
AltitudeRef = 0;
Latitude = "35.65283333333333";
LatitudeRef = N;
Longitude = "139.697";
LongitudeRef = E;
TimeStamp = "16:15:16.30";
}

16
15
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?