iOS读取图片附加信息

首先需要引入ALAssetsLibrary库。

首先需要用户授予定位服务权限。

读取图片附加信息的代码如下:

 1  NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];
 2             
 3 ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
 4 [library assetForURL:assetURL resultBlock:^(ALAsset *asset) {
 5     NSDictionary *metadata = asset.defaultRepresentation.metadata;
 6 
 7     NSLog(@"%@", metadata);
 8 }
 9 failureBlock:^(NSError *error) {}];

打印出的图片附加信息如下:

{

    ColorModel = RGB;

    DPIHeight = 72;

    DPIWidth = 72;

    Depth = 8;

    Orientation = 3;

    PixelHeight = 1936;

    PixelWidth = 2592;

    "{Exif}" =     {

        ApertureValue = "2.970854";

        ColorSpace = 1;

        ComponentsConfiguration =         (

            1,

            2,

            3,

            0

        );

        DateTimeDigitized = "2012:08:01 19:39:08";

        DateTimeOriginal = "2012:08:01 19:39:08";

        ExifVersion =         (

            2,

            2,

            1

        );

        ExposureMode = 0;

        ExposureProgram = 2;

        ExposureTime = "0.06666667";

        FNumber = "2.8";

        Flash = 16;

        FlashPixVersion =         (

            1,

            0

        );

        FocalLength = "3.85";

        ISOSpeedRatings =         (

            100

        );

        MeteringMode = 5;

        PixelXDimension = 2592;

        PixelYDimension = 1936;

        SceneCaptureType = 0;

        SensingMethod = 2;

        Sharpness = 2;

        ShutterSpeedValue = "3.9112";

        SubjectArea =         (

            1295,

            967,

            699,

            696

        );

        WhiteBalance = 0;

    };

    "{GPS}" =     {

        Altitude = "84.62079";

        AltitudeRef = 0;

        ImgDirection = "75.96286";

        ImgDirectionRef = T;

        Latitude = "39.89233333333333";

        LatitudeRef = N;

        Longitude = "116.4566666666667";

        LongitudeRef = E;

        TimeStamp = "11:52:22.00";

    };

    "{TIFF}" =     {

        DateTime = "2012:08:01 19:39:08";

        Make = Apple;

        Model = "iPhone 4";

        Orientation = 3;

        ResolutionUnit = 2;

        Software = "4.3.3";

        XResolution = 72;

        YResolution = 72;

        "_YCbCrPositioning" = 1;

    };

}

posted @ 2012-08-02 10:44  大师赵  阅读(1198)  评论(0编辑  收藏  举报