2

I'm using the ios CGImageSourceCopyPropertiesAtIndex to extract a lot of metadata for images on ios. But I cannot extract all metadata like the ones shown in Mac Preview app or the exiftool command.

I'm missing the "Picture Style" and "Canon" informations mostly.

How I'm reading the metadata:

NSURL *imageFileURL = [NSURL fileURLWithPath:filePath];
CGImageSourceRef imageSource = CGImageSourceCreateWithURL((CFURLRef)CFBridgingRetain(imageFileURL), NULL);
CFDictionaryRef props = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL);
NSLog(@"%@", props);

Anyone have a hint ?

This is the information using Preview

enter image description here

This is the information from the NSLog:

2013-04-02 09:50:06.885 i2[67169:1f0f] {
ColorModel = RGB;
DPIHeight = 72;
DPIWidth = 72;
Depth = 8;
Orientation = 1;
PixelHeight = 1728;
PixelWidth = 2592;
"{Exif}" =     {
    ApertureValue = "5.375";
    BodySerialNumber = 1280809746;
    ColorSpace = 1;
    ComponentsConfiguration =         (
        1,
        2,
        3,
        0
    );
    CustomRendered = 0;
    DateTimeDigitized = "2012:12:24 12:58:46";
    DateTimeOriginal = "2012:12:24 12:58:46";
    ExifVersion =         (
        2,
        3
    );
    ExposureBiasValue = 0;
    ExposureMode = 1;
    ExposureProgram = 1;
    ExposureTime = "0.003125";
    FNumber = "6.3";
    Flash = 16;
    FlashPixVersion =         (
        1,
        0
    );
    FocalLength = 22;
    FocalPlaneResolutionUnit = 2;
    FocalPlaneXResolution = "2857.773";
    FocalPlaneYResolution = "2904.202";
    ISOSpeedRatings =         (
        3200
    );
    LensModel = "EF-S10-22mm f/3.5-4.5 USM";
    LensSpecification =         (
        10,
        22,
        0,
        0
    );
    MeteringMode = 5;
    PixelXDimension = 2592;
    PixelYDimension = 1728;
    SceneCaptureType = 0;
    ShutterSpeedValue = "8.375";
    SubsecTime = 35;
    SubsecTimeDigitized = 35;
    SubsecTimeOriginal = 35;
    WhiteBalance = 1;
};
"{IPTC}" =     {
    StarRating = 0;
};
"{TIFF}" =     {
    DateTime = "2012:12:24 12:58:46";
    Make = Canon;
    Model = "Canon EOS 7D";
    Orientation = 1;
    ResolutionUnit = 2;
    XResolution = 72;
    YResolution = 72;
    "_YCbCrPositioning" = 2;
};
}
2
  • Not sure what you're using this data for but an image is never guaranteed to contain any metadata or exif data, not to mention it isn't a standard so every image could be different.
    – Tim
    Mar 25, 2013 at 21:10
  • I'm trying to extract information of pictures taken by external cameras. When doing that in desktop programs more information is available than when using the CGImageSourceRef. So was wondering if it was possible to get more information using existing libraries.
    – stoffer
    Mar 27, 2013 at 7:47

1 Answer 1

1

Note that kCGImagePropertyMakerCanonDictionary, kCGImagePropertyExifAuxDictionary, and kCGImagePropertyTIFFDictionary are not options that CGImageSourceCopyPropertiesAtIndex understands. They're keys in the dictionary it returns. It doesn't appear to cause any problems to pass them, but it also doesn't achieve anything.

There's no declared property key to access the picture style data that I can see, but it does appear to be returned by CGImageSourceCopyPropertiesAtIndex anyway. If you dump out the props dictionary you should see a {PictureStyle} key that contains a dictionary with the information of interest. You'll also see a {MakerCanon}key. That corresponds to the constant kCGImagePropertyMakerCanonDictionary, and the properties within that dictionary are those described in the relevant section of the documentation.

5
  • Yes - it was a code snippet from some old test code. Found out how to use the CGImageSourceCopyPropertiesAtIndex. My problem is, that when using that function no {MakerCanon} or {PictureStyle} is in the props, but when using MacOS Preview there is such information about the picture. Have updated the post with relevant screenshots and props dump
    – stoffer
    Apr 2, 2013 at 7:54
  • What OS version are you testing this on? I tested on OS X 10.8.x and was able to retrieve the picture style and manufacturer-specific data from raw riles captured by both Canon and Olympus cameras. I'd expect it to work in the same way on iOS 6.x as it does on OS X 10.8.x.
    – bdash
    Apr 2, 2013 at 8:01
  • I'm testing on OS X 10.8.3 and iOS 6.1.3. Works fine on OS X, not in iOS
    – stoffer
    Apr 2, 2013 at 8:11
  • Based on what you've described, and the fact that this works on OS X, this sounds like a bug in the CGImageSource API on iOS. I'd suggest filing a bug report at bugreport.apple.com with a test application demonstrating the issue.
    – bdash
    Apr 2, 2013 at 8:33
  • Made sample projects in iOS and OSX for the same file showing that properties are missing when using the iOS SDK. Created a bug report on apple site. Will update thread when news arive. Thanks for the help
    – stoffer
    Apr 2, 2013 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.