Click here to Skip to main content
15,861,168 members
Articles / Programming Languages / C#
Article

ExifTagCollection - An EXIF metadata extraction library

Rate me:
Please Sign up or sign in to vote.
4.87/5 (43 votes)
24 Jun 2008CPOL4 min read 414.4K   10.3K   101   29
A library to extract EXIF information from images, compliant with the EXIF 2.2 standard.

Image 1

Introduction

This library is inspired by the ExifExtractor class by Asim Goheer. The problem with ExifExtractor was that it does not support some tags defined in the EXIF 2.2 standard, like tags related to GPS data, so I decided to modify it, but, eventually, decided to write it from scratch, though I reused some of Asim's code..

The ExifTagsCollection is based on IEnumerable<T>, and holds a collection of ExifTag classes that encapsulates an EXIF tag.

The ExifTag class holds the field name, description, ID, and the value for the given tag. A couple of convenient classes have been added:

  • Rational - for signed rational values
  • URational - for unsigned rational values
  • GPSRational - for GPS 24 bit data

Using the code

Using the code is pretty straightforward. Here is an example of listing all the tags in the console:

C#
// See other constructors, for creating ExifTagCollection with Image instance, etc.
ExifTagCollection exif = new ExifTagCollection(@"c:\somefile.jpg");

foreach (ExifTag tag in exif)
    Console.Out.WriteLine(tag);

Another example for getting a specific tag by ID:

C#
ExifTagCollection exif = new ExifTagCollection(@"c:\somefile.jpg");

ExifTag tag = exif[2];
Console.Out.WriteLine(tag);
//OUTPUT: Latitude (GPSLatitude) = 22° 47' 35,35"

Supported EXIF fields:

  • ImageWidth - Image width
  • ImageHeight - Image height
  • GPSVersionID - GPS tag version
  • GPSAltitudeRef - Altitude reference
  • StripOffsets - Image data location
  • RowsPerStrip - Number of rows per strip
  • StripByteCounts - Bytes per compressed strip
  • PixelXDimension - Valid image width
  • PixelYDimension - Valid image height
  • BitsPerSample - Number of bits per component
  • Compression - Compression scheme
  • PhotometricInterpretation - Pixel composition
  • Orientation - Orientation of image
  • SamplesPerPixel - Number of components
  • PlanarConfiguration - Image data arrangement
  • YCbCrSubSampling - Sub-sampling ratio of Y to C
  • YCbCrPositioning - Y and C positioning
  • ResolutionUnit - Unit of X and Y resolution
  • TransferFunction - Transfer function
  • ColorSpace - Color space information
  • ExposureProgram - Exposure program
  • ISOSpeedRatings - ISO speed rating
  • MeteringMode - Metering mode
  • LightSource - Light source
  • Flash - Flash
  • SubjectArea - Subject area
  • FocalPlaneResolutionUnit - Focal plane resolution unit
  • SubjectLocation - Subject location
  • SensingMethod - Sensing method
  • CustomRendered - Custom image processing
  • ExposureMode - Exposure mode
  • WhiteBalance - White balance
  • FocalLengthIn35mmFilm - Focal length in 35 mm film
  • SceneCaptureType - Scene capture type
  • Contrast - Contrast
  • Saturation - Saturation
  • Sharpness - Sharpness
  • SubjectDistanceRange - Subject distance range
  • GPSDifferential - GPS differential correction
  • ShutterSpeedValue - Shutter speed
  • BrightnessValue - Brightness
  • ExposureBiasValue - Exposure bias
  • JPEGInterchangeFormat - Offset to JPEG SOI
  • JPEGInterchangeFormatLength - Bytes of JPEG data
  • XResolution - Image resolution in width direction
  • YResolution - Image resolution in height direction
  • WhitePoint - White point chromaticity
  • PrimaryChromaticities - Chromaticities of primaries
  • YCbCrCoefficients - Color space transformation matrix coefficients
  • ReferenceBlackWhite - Pair of black and white reference values
  • CompressedBitsPerPixel - Image compression mode
  • ExposureTime - Exposure time
  • FNumber - F number
  • ApertureValue - Aperture
  • MaxApertureValue - Maximum lens aperture
  • SubjectDistance - Subject distance
  • FocalLength - Lens focal length
  • FlashEnergy - Flash energy
  • FocalPlaneXResolution - Focal plane X resolution
  • FocalPlaneYResolution - Focal plane Y resolution
  • ExposureIndex - Exposure index
  • DigitalZoomRatio - Digital zoom ratio
  • GainControl - Gain control
  • GPSLatitude - Latitude
  • GPSLongitude - Longitude
  • GPSAltitude - Altitude
  • GPSTimeStamp - GPS time (atomic clock)
  • GPSDOP - Measurement precision
  • GPSSpeed - Speed of GPS receiver
  • GPSTrack - Direction of movement
  • GPSImgDirection - Direction of image
  • GPSDestLatitude - Latitude of destination
  • GPSDestLongitude - Longitude of destination
  • GPSDestBearing - Bearing of destination
  • GPSDestDistance - Distance to destination
  • DateTime - File change date and time
  • ImageDescription - Image title
  • Make - Image input equipment manufacturer
  • Model - Image input equipment model
  • Software - Software used
  • Artist - Person who created the image
  • Copyright - Copyright holder
  • RelatedSoundFile - Related audio file
  • DateTimeOriginal - Date and time of original data generation
  • DateTimeDigitized - Date and time of digital data generation
  • SubSecTime - DateTime subseconds
  • SubSecTimeOriginal - DateTimeOriginal subseconds
  • SubSecTimeDigitized - DateTimeDigitized subseconds
  • ImageUniqueID - Unique image ID
  • SpectralSensitivity - Spectral sensitivity
  • GPSLatitudeRef - North or South Latitude
  • GPSLongitudeRef - East or West Longitude
  • GPSSatellites - GPS satellites used for measurement
  • GPSStatus - GPS receiver status
  • GPSMeasureMode - GPS measurement mode
  • GPSSpeedRef - Speed unit
  • GPSTrackRef - Reference for direction of movement
  • GPSImgDirectionRef - Reference for direction of image
  • GPSMapDatum - Geodetic survey data used
  • GPSDestLatitudeRef - Reference for latitude of destination
  • GPSDestLongitudeRef - Reference for longitude of destination
  • GPSDestBearingRef - Reference for bearing of destination
  • GPSDestDistanceRef - Reference for distance to destination
  • GPSDateStamp - GPS date
  • OECF - Optoelectric conversion factor
  • SpatialFrequencyResponse - Spatial frequency response
  • FileSource - File source
  • SceneType - Scene type
  • CFAPattern - CFA pattern
  • DeviceSettingDescription - Device settings description
  • ExifVersion - EXIF version
  • FlashpixVersion - Supported Flashpix version
  • ComponentsConfiguration - Meaning of each component
  • MakerNote - Manufacturer notes
  • UserComment - User comments
  • GPSProcessingMethod - Name of GPS processing method
  • GPSAreaInformation - Name of GPS area

History

  • Initial release.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Virage Logic Corporation
Armenia Armenia
I'm a developer focusing on Quality Assurance at the Virage Logic Corporation.
My main responsibilities include the development and maintenance of an environment for automated quality assurance of the Verilog IP provided by our company.

Comments and Discussions

 
QuestionIntegrate into a Xamarin.Forms app Pin
jodi3195-Nov-21 0:28
jodi3195-Nov-21 0:28 
QuestionI want same application in php or javascript.. Pin
Sunil Kumar Rajashreshtaha26-Feb-17 19:14
Sunil Kumar Rajashreshtaha26-Feb-17 19:14 
QuestionVarbinary image from SQL Pin
Member 1210308131-Oct-15 11:26
Member 1210308131-Oct-15 11:26 
AnswerRe: Varbinary image from SQL Pin
Member 121030811-Nov-15 9:22
Member 121030811-Nov-15 9:22 
QuestionRMETA Pin
robertzsugya1-Apr-15 22:06
robertzsugya1-Apr-15 22:06 
Questionfor Large file it does not work. e.g. grater than 12MB Pin
Pradeep Gupta6-Jun-14 3:40
Pradeep Gupta6-Jun-14 3:40 
GeneralMy vote of 5 Pin
bbcdk16-May-11 11:23
bbcdk16-May-11 11:23 
QuestionSupport DNG format? Pin
Member 767189814-Feb-11 4:05
Member 767189814-Feb-11 4:05 
GeneralMy vote of 4 Pin
inksmithy22-Jan-11 2:08
inksmithy22-Jan-11 2:08 
GeneralMy vote of 4 Pin
Slacker00720-Jan-11 0:25
professionalSlacker00720-Jan-11 0:25 
GeneralExcellent code ! Works perfectly ! Pin
Dan Clark17-Feb-10 12:01
Dan Clark17-Feb-10 12:01 
GeneralPretty cool Pin
Member 292415727-Sep-09 10:04
Member 292415727-Sep-09 10:04 
Generaledit exif value Pin
Huisheng Chen20-Apr-09 19:55
Huisheng Chen20-Apr-09 19:55 
GeneralRe: edit exif value Pin
glenneroo27-Nov-10 15:14
glenneroo27-Nov-10 15:14 
Jokehello!:) Pin
diligentpig3-Nov-08 18:20
diligentpig3-Nov-08 18:20 
GeneralRe: hello!:) Pin
Lev Danielyan4-Nov-08 1:47
Lev Danielyan4-Nov-08 1:47 
GeneralRe: hello!:) Pin
diligentpig5-Nov-08 17:59
diligentpig5-Nov-08 17:59 
GeneralRe: hello!:) Pin
Lev Danielyan5-Nov-08 19:23
Lev Danielyan5-Nov-08 19:23 
GeneralRe: hello!:) Pin
diligentpig8-Nov-08 22:48
diligentpig8-Nov-08 22:48 
GeneralRe: hello!:) Pin
diligentpig9-Nov-08 16:40
diligentpig9-Nov-08 16:40 
GeneralRe: hello!:) Pin
Lev Danielyan9-Nov-08 22:02
Lev Danielyan9-Nov-08 22:02 
GeneralDuplicate tag in image Pin
Wormpurple8-Aug-08 3:13
Wormpurple8-Aug-08 3:13 
GeneralRe: Duplicate tag in image Pin
Lev Danielyan8-Aug-08 3:35
Lev Danielyan8-Aug-08 3:35 
GeneralBadly designed code... Pin
Eugene Sichkar27-Jun-08 9:11
Eugene Sichkar27-Jun-08 9:11 
GeneralRe: Badly designed code... Pin
Lev Danielyan27-Jun-08 21:28
Lev Danielyan27-Jun-08 21:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.