EXIF. How to get EXIF data in iOS?

EXIF (Exchangeable image file format) — is a standard that specifies the formats for images, sound, and ancillary tags used by digital cameras (including smartphones), scanners and other systems handling image and sound files recorded by digital cameras. Standard allows to add to photos or other media files some additional information (metadata). Standard is flexible, allows to save location from GPS tracker, or allows to save some specific information only from current camera. For example EXIF can store: camera manufacturer, Information about the ownership of the right,
exposure, diaphragm, ISO, frame resolution, size of the matrix, date and time, camera orientation, type of white balance, the geographic coordinates, etc.

In iOS it’s really simple to get EXIF data from ALAsset class. For example:

ALAssetRepresentation *representation = [asset defaultRepresentation];
NSDictionary *metadataDict = [representation metadata];

And we will have the following information:

{
ColorModel = RGB;
DPIHeight = 72;
DPIWidth = 72;
Depth = 8;
Orientation = 6;
PixelHeight = 1936;
PixelWidth = 2592;
"{Exif}" = {
ApertureValue = "2.52606882168926";
BrightnessValue = "2.411431513903193";
ColorSpace = 1;
ComponentsConfiguration = (
1,
2,
3,
0
);
DateTimeDigitized = "2015:04:16 11:42:41";
DateTimeOriginal = "2015:04:16 11:42:41";
ExifVersion = (
2,
2,
1
);
ExposureBiasValue = 0;
ExposureMode = 0;
ExposureProgram = 2;
ExposureTime = "0.04166666666666666";
FNumber = "2.4";
Flash = 24;
FlashPixVersion = (
1,
0
);
FocalLenIn35mmFilm = 33;
FocalLength = "3.3";
ISOSpeedRatings = (
160
);
LensMake = Apple;
LensModel = "iPod touch back camera 3.3mm f/2.4";
LensSpecification = (
"3.3",
"3.3",
"2.4",
"2.4"
);
MeteringMode = 5;
PixelXDimension = 2592;
PixelYDimension = 1936;
SceneCaptureType = 0;
SceneType = 1;
SensingMethod = 2;
ShutterSpeedValue = "4.584985835694051";
SubjectArea = (
1295,
967,
699,
696
);
SubsecTimeDigitized = 505;
SubsecTimeOriginal = 505;
WhiteBalance = 0;
};
"{GPS}" = {
Altitude = "113.3378016085791";
AltitudeRef = 0;
DateStamp = "2015:04:16";
Latitude = "49.99335";
LatitudeRef = N;
Longitude = "36.23998333333333";
LongitudeRef = E;
Speed = 0;
SpeedRef = K;
TimeStamp = "08:42:37";
};
"{MakerApple}" = {
1 = 2;
3 = {
epoch = 0;
flags = 1;
timescale = 1000000000;
value = 181054764748833;
};
4 = 1;
5 = 239;
6 = 245;
7 = 1;
8 = (
"-0.06626953",
"-0.5302355",
"-0.8595031"
);
};
"{TIFF}" = {
DateTime = "2015:04:16 11:42:41";
Make = Apple;
Model = "iPod touch";
Orientation = 6;
ResolutionUnit = 2;
Software = "8.3";
XResolution = 72;
YResolution = 72;
};
}

Or if you have UIImage class, you can try this:

NSData* data = UIImageJPEGRepresentation(image, 1.0);
CGImageSourceRef source = CGImageSourceCreateWithData((CFDataRef)data, NULL);
NSDictionary *metadata = (NSDictionary *) CFBridgingRelease(CGImageSourceCopyPropertiesAtIndex(source, 0, NULL));

Or with help some library - iphone-exif.

Show your support

Clapping shows how much you appreciated Maxim Bilan’s story.