Search code examples
iosiphoneobjective-ccamera-roll

how to detect if image from photo library was taken by iPhone camera or imported


in the app i am developing, i ought to know if the picture selected by the user was originally taken by the iPhone's camera, or is it a picture taken from any other source, as from the internet or imported from external camera etc.


Solution

  • As @yoeriboven pointed out, you should check the image EXIF. The easiest way to access it would be:

    ALAssetRepresentation *assetRep = [asset defaultRepresentation];
    NSDictionary *metaData = [assetRep metadata];
    

    This should be the relevant section:

    "{TIFF}" = {
        DateTime = "2012:12:13 01:21:55";
        Make = Apple;
        Model = "iPhone 4";
        Orientation = 6;
        ResolutionUnit = 2;
        Software = "6.0.1";
        XResolution = 72;
        YResolution = 72;
        "_YCbCrPositioning" = 1;
    };
    

    I wouldn't count only on the location property. Non iPhone photos can have location as well.