获取图片EXIF信息

EXIFextractor.cs

 

ExpandedBlockStart.gif EXIFextractor.cs
using  System;
using  System.Text;
using  System.Collections;
using  System.Drawing.Imaging;
using  System.Reflection;
using  System.IO; 

namespace  EXIF
{
    
///   <summary>
    
///  EXIFextractor Class
    
///  
    
///   </summary>
     public   class  EXIFextractor : IEnumerable
    {
        
///   <summary>
        
///  Get the individual property value by supplying property name
        
///  These are the valid property names :
        
///  
        
///  "Exif IFD"
        
///  "Gps IFD"
        
///  "New Subfile Type"
        
///  "Subfile Type"
        
///  "Image Width"
        
///  "Image Height"
        
///  "Bits Per Sample"
        
///  "Compression"
        
///  "Photometric Interp"
        
///  "Thresh Holding"
        
///  "Cell Width"
        
///  "Cell Height"
        
///  "Fill Order"
        
///  "Document Name"
        
///  "Image Description"
        
///  "Equip Make"
        
///  "Equip Model"
        
///  "Strip Offsets"
        
///  "Orientation"
        
///  "Samples PerPixel"
        
///  "Rows Per Strip"
        
///  "Strip Bytes Count"
        
///  "Min Sample Value"
        
///  "Max Sample Value"
        
///  "X Resolution"
        
///  "Y Resolution"
        
///  "Planar Config"
        
///  "Page Name"
        
///  "X Position"
        
///  "Y Position"
        
///  "Free Offset"
        
///  "Free Byte Counts"
        
///  "Gray Response Unit"
        
///  "Gray Response Curve"
        
///  "T4 Option"
        
///  "T6 Option"
        
///  "Resolution Unit"
        
///  "Page Number"
        
///  "Transfer Funcition"
        
///  "Software Used"
        
///  "Date Time"
        
///  "Artist"
        
///  "Host Computer"
        
///  "Predictor"
        
///  "White Point"
        
///  "Primary Chromaticities"
        
///  "ColorMap"
        
///  "Halftone Hints"
        
///  "Tile Width"
        
///  "Tile Length"
        
///  "Tile Offset"
        
///  "Tile ByteCounts"
        
///  "InkSet"
        
///  "Ink Names"
        
///  "Number Of Inks"
        
///  "Dot Range"
        
///  "Target Printer"
        
///  "Extra Samples"
        
///  "Sample Format"
        
///  "S Min Sample Value"
        
///  "S Max Sample Value"
        
///  "Transfer Range"
        
///  "JPEG Proc"
        
///  "JPEG InterFormat"
        
///  "JPEG InterLength"
        
///  "JPEG RestartInterval"
        
///  "JPEG LosslessPredictors"
        
///  "JPEG PointTransforms"
        
///  "JPEG QTables"
        
///  "JPEG DCTables"
        
///  "JPEG ACTables"
        
///  "YCbCr Coefficients"
        
///  "YCbCr Subsampling"
        
///  "YCbCr Positioning"
        
///  "REF Black White"
        
///  "ICC Profile"
        
///  "Gamma"
        
///  "ICC Profile Descriptor"
        
///  "SRGB RenderingIntent"
        
///  "Image Title"
        
///  "Copyright"
        
///  "Resolution X Unit"
        
///  "Resolution Y Unit"
        
///  "Resolution X LengthUnit"
        
///  "Resolution Y LengthUnit"
        
///  "Print Flags"
        
///  "Print Flags Version"
        
///  "Print Flags Crop"
        
///  "Print Flags Bleed Width"
        
///  "Print Flags Bleed Width Scale"
        
///  "Halftone LPI"
        
///  "Halftone LPIUnit"
        
///  "Halftone Degree"
        
///  "Halftone Shape"
        
///  "Halftone Misc"
        
///  "Halftone Screen"
        
///  "JPEG Quality"
        
///  "Grid Size"
        
///  "Thumbnail Format"
        
///  "Thumbnail Width"
        
///  "Thumbnail Height"
        
///  "Thumbnail ColorDepth"
        
///  "Thumbnail Planes"
        
///  "Thumbnail RawBytes"
        
///  "Thumbnail Size"
        
///  "Thumbnail CompressedSize"
        
///  "Color Transfer Function"
        
///  "Thumbnail Data"
        
///  "Thumbnail ImageWidth"
        
///  "Thumbnail ImageHeight"
        
///  "Thumbnail BitsPerSample"
        
///  "Thumbnail Compression"
        
///  "Thumbnail PhotometricInterp"
        
///  "Thumbnail ImageDescription"
        
///  "Thumbnail EquipMake"
        
///  "Thumbnail EquipModel"
        
///  "Thumbnail StripOffsets"
        
///  "Thumbnail Orientation"
        
///  "Thumbnail SamplesPerPixel"
        
///  "Thumbnail RowsPerStrip"
        
///  "Thumbnail StripBytesCount"
        
///  "Thumbnail ResolutionX"
        
///  "Thumbnail ResolutionY"
        
///  "Thumbnail PlanarConfig"
        
///  "Thumbnail ResolutionUnit"
        
///  "Thumbnail TransferFunction"
        
///  "Thumbnail SoftwareUsed"
        
///  "Thumbnail DateTime"
        
///  "Thumbnail Artist"
        
///  "Thumbnail WhitePoint"
        
///  "Thumbnail PrimaryChromaticities"
        
///  "Thumbnail YCbCrCoefficients"
        
///  "Thumbnail YCbCrSubsampling"
        
///  "Thumbnail YCbCrPositioning"
        
///  "Thumbnail RefBlackWhite"
        
///  "Thumbnail CopyRight"
        
///  "Luminance Table"
        
///  "Chrominance Table"
        
///  "Frame Delay"
        
///  "Loop Count"
        
///  "Pixel Unit"
        
///  "Pixel PerUnit X"
        
///  "Pixel PerUnit Y"
        
///  "Palette Histogram"
        
///  "Exposure Time"
        
///  "F-Number"
        
///  "Exposure Prog"
        
///  "Spectral Sense"
        
///  "ISO Speed"
        
///  "OECF"
        
///  "Ver"
        
///  "DTOrig"
        
///  "DTDigitized"
        
///  "CompConfig"
        
///  "CompBPP"
        
///  "Shutter Speed"
        
///  "Aperture"
        
///  "Brightness"
        
///  "Exposure Bias"
        
///  "MaxAperture"
        
///  "SubjectDist"
        
///  "Metering Mode"
        
///  "LightSource"
        
///  "Flash"
        
///  "FocalLength"
        
///  "Maker Note"
        
///  "User Comment"
        
///  "DTSubsec"
        
///  "DTOrigSS"
        
///  "DTDigSS"
        
///  "FPXVer"
        
///  "ColorSpace"
        
///  "PixXDim"
        
///  "PixYDim"
        
///  "RelatedWav"
        
///  "Interop"
        
///  "FlashEnergy"
        
///  "SpatialFR"
        
///  "FocalXRes"
        
///  "FocalYRes"
        
///  "FocalResUnit"
        
///  "Subject Loc"
        
///  "Exposure Index"
        
///  "Sensing Method"
        
///  "FileSource"
        
///  "SceneType"
        
///  "CfaPattern"
        
///  "Gps Ver"
        
///  "Gps LatitudeRef"
        
///  "Gps Latitude"
        
///  "Gps LongitudeRef"
        
///  "Gps Longitude"
        
///  "Gps AltitudeRef"
        
///  "Gps Altitude"
        
///  "Gps GpsTime"
        
///  "Gps GpsSatellites"
        
///  "Gps GpsStatus"
        
///  "Gps GpsMeasureMode"
        
///  "Gps GpsDop"
        
///  "Gps SpeedRef"
        
///  "Gps Speed"
        
///  "Gps TrackRef"
        
///  "Gps Track"
        
///  "Gps ImgDirRef"
        
///  "Gps ImgDir"
        
///  "Gps MapDatum"
        
///  "Gps DestLatRef"
        
///  "Gps DestLat"
        
///  "Gps DestLongRef"
        
///  "Gps DestLong"
        
///  "Gps DestBearRef"
        
///  "Gps DestBear"
        
///  "Gps DestDistRef"
        
///  "Gps DestDist"
        
///   </summary>
         public   object   this [ string  index]
        {
            
get
            {
                
return  properties[index];
            }
        }
        
//
         private  System.Drawing.Bitmap bmp;
        
//
         private   string  data;
        
//
         private  translation myHash;
        
//
         private  Hashtable properties;
        
//
         internal   int  Count
        {
            
get
            {
                
return   this .properties.Count;
            }
        }
        
//
         string  sp;
        
///   <summary>
        
///  
        
///   </summary>
        
///   <param name="id"></param>
        
///   <param name="len"></param>
        
///   <param name="type"></param>
        
///   <param name="data"></param>
         public   void  setTag( int  id,  string  data)
        {
            Encoding ascii 
=  Encoding.ASCII;
            
this .setTag(id, data.Length,  0x2 , ascii.GetBytes(data));
        }
        
///   <summary>
        
///  
        
///   </summary>
        
///   <param name="id"></param>
        
///   <param name="len"></param>
        
///   <param name="type"></param>
        
///   <param name="data"></param>
         public   void  setTag( int  id,  int  len,  short  type,  byte [] data)
        {
            PropertyItem p 
=  CreatePropertyItem(type, id, len, data);
            
this .bmp.SetPropertyItem(p);
            buildDB(
this .bmp.PropertyItems);
        }
        
///   <summary>
        
///  
        
///   </summary>
        
///   <param name="type"></param>
        
///   <param name="tag"></param>
        
///   <param name="len"></param>
        
///   <param name="value"></param>
        
///   <returns></returns>
         private   static  PropertyItem CreatePropertyItem( short  type,  int  tag,  int  len,  byte [] value)
        {
            PropertyItem item;

            
//  Loads a PropertyItem from a Jpeg image stored in the assembly as a resource.
            Assembly assembly  =  Assembly.GetExecutingAssembly();
            Stream emptyBitmapStream 
=  assembly.GetManifestResourceStream( " EXIFextractor.decoy.jpg " );
            System.Drawing.Image empty 
=  System.Drawing.Image.FromStream(emptyBitmapStream);

            item 
=  empty.PropertyItems[ 0 ];

            
//  Copies the data to the property item.
            item.Type  =  type;
            item.Len 
=  len;
            item.Id 
=  tag;
            item.Value 
=   new   byte [value.Length];
            value.CopyTo(item.Value, 
0 );

            
return  item;
        }
        
///   <summary>
        
///  
        
///   </summary>
        
///   <param name="bmp"></param>
        
///   <param name="sp"></param>
         public  EXIFextractor( ref  System.Drawing.Bitmap bmp,  string  sp)
        {
            properties 
=   new  Hashtable();
            
//
             this .bmp  =  bmp;
            
this .sp  =  sp;
            
//
            myHash  =   new  translation();
            buildDB(
this .bmp.PropertyItems);
        }
        
string  msp  =   "" ;
        
public  EXIFextractor( ref  System.Drawing.Bitmap bmp,  string  sp,  string  msp)
        {
            properties 
=   new  Hashtable();
            
this .sp  =  sp;
            
this .msp  =  msp;
            
this .bmp  =  bmp;
            
//     
            myHash  =   new  translation();
            
this .buildDB(bmp.PropertyItems);

        }
        
public   static  PropertyItem[] GetExifProperties( string  fileName)
        {
            FileStream stream 
=   new  FileStream(fileName, FileMode.Open, FileAccess.Read);
            System.Drawing.Image image 
=  System.Drawing.Image.FromStream(stream,
                
/*  useEmbeddedColorManagement =  */   true ,
                
/*  validateImageData =  */   false );
            
return  image.PropertyItems;
        }
        
public  EXIFextractor( string  file,  string  sp,  string  msp)
        {
            properties 
=   new  Hashtable();
            
this .sp  =  sp;
            
this .msp  =  msp;

            myHash 
=   new  translation();
            
//     
             this .buildDB(GetExifProperties(file));

        }

        
///   <summary>
        
///  
        
///   </summary>
         private   void  buildDB(System.Drawing.Imaging.PropertyItem[] parr)
            {
                properties.Clear();
                
//
                data  =   "" ;
                
//
                Encoding ascii  =  Encoding.ASCII;
                
//
                 foreach  (System.Drawing.Imaging.PropertyItem p  in  parr)
                {
                    
string  v  =   "" ;
                    
string  name  =  ( string )myHash[p.Id];
                    
//  tag not found. skip it
                     if  (name  ==   null continue ;
                    
//
                    data  +=  name  +   " " ;
                    
//
                    
// 1 = BYTE An 8-bit unsigned integer.,
                     if  (p.Type  ==   0x1 )
                    {
                        v 
=  p.Value[ 0 ].ToString();
                    }
                    
// 2 = ASCII An 8-bit byte containing one 7-bit ASCII code. The final byte is terminated with NULL.,
                     else   if  (p.Type  ==   0x2 )
                    {
                        
//  string     
                        v  =  ascii.GetString(p.Value);
                    }
                    
// 3 = SHORT A 16-bit (2 -byte) unsigned integer,
                     else   if  (p.Type  ==   0x3 )
                    {
                        
//  orientation  //  lookup table     
                         switch  (p.Id)
                        {
                            
case   0x8827 //  ISO
                                v  =   " ISO- "   +  convertToInt16U(p.Value).ToString();
                                
break ;
                            
case   0xA217 //  sensing method
                                {
                                    
switch  (convertToInt16U(p.Value))
                                    {
                                        
case   1 : v  =   " Not defined " break ;
                                        
case   2 : v  =   " One-chip color area sensor " break ;
                                        
case   3 : v  =   " Two-chip color area sensor " break ;
                                        
case   4 : v  =   " Three-chip color area sensor " break ;
                                        
case   5 : v  =   " Color sequential area sensor " break ;
                                        
case   7 : v  =   " Trilinear sensor " break ;
                                        
case   8 : v  =   " Color sequential linear sensor " break ;
                                        
default : v  =   "  reserved " break ;
                                    }
                                }
                                
break ;
                            
case   0x8822 //  aperture 
                                 switch  (convertToInt16U(p.Value))
                                {
                                    
case   0 : v  =   " Not defined " break ;
                                    
case   1 : v  =   " Manual " break ;
                                    
case   2 : v  =   " Normal program " break ;
                                    
case   3 : v  =   " Aperture priority " break ;
                                    
case   4 : v  =   " Shutter priority " break ;
                                    
case   5 : v  =   " Creative program (biased toward depth of field) " break ;
                                    
case   6 : v  =   " Action program (biased toward fast shutter speed) " break ;
                                    
case   7 : v  =   " Portrait mode (for closeup photos with the background out of focus) " break ;
                                    
case   8 : v  =   " Landscape mode (for landscape photos with the background in focus) " break ;
                                    
default : v  =   " reserved " break ;
                                }
                                
break ;
                            
case   0x9207 //  metering mode
                                 switch  (convertToInt16U(p.Value))
                                {
                                    
case   0 : v  =   " unknown " break ;
                                    
case   1 : v  =   " Average " break ;
                                    
case   2 : v  =   " CenterWeightedAverage " break ;
                                    
case   3 : v  =   " Spot " break ;
                                    
case   4 : v  =   " MultiSpot " break ;
                                    
case   5 : v  =   " Pattern " break ;
                                    
case   6 : v  =   " Partial " break ;
                                    
case   255 : v  =   " Other " break ;
                                    
default : v  =   " reserved " break ;
                                }
                                
break ;
                            
case   0x9208 //  light source
                                {
                                    
switch  (convertToInt16U(p.Value))
                                    {
                                        
case   0 : v  =   " unknown " break ;
                                        
case   1 : v  =   " Daylight " break ;
                                        
case   2 : v  =   " Fluorescent " break ;
                                        
case   3 : v  =   " Tungsten " break ;
                                        
case   17 : v  =   " Standard light A " break ;
                                        
case   18 : v  =   " Standard light B " break ;
                                        
case   19 : v  =   " Standard light C " break ;
                                        
case   20 : v  =   " D55 " break ;
                                        
case   21 : v  =   " D65 " break ;
                                        
case   22 : v  =   " D75 " break ;
                                        
case   255 : v  =   " other " break ;
                                        
default : v  =   " reserved " break ;
                                    }
                                }
                                
break ;
                            
case   0x9209 :
                                {
                                    
switch  (convertToInt16U(p.Value))
                                    {
                                        
case   0 : v  =   " Flash did not fire " break ;
                                        
case   1 : v  =   " Flash fired " break ;
                                        
case   5 : v  =   " Strobe return light not detected " break ;
                                        
case   7 : v  =   " Strobe return light detected " break ;
                                        
default : v  =   " reserved " break ;
                                    }
                                }
                                
break ;
                            
default :
                                v 
=  convertToInt16U(p.Value).ToString();
                                
break ;
                        }
                    }
                    
// 4 = LONG A 32-bit (4 -byte) unsigned integer,
                     else   if  (p.Type  ==   0x4 )
                    {
                        
//  orientation  //  lookup table     
                        v  =  convertToInt32U(p.Value).ToString();
                    }
                    
// 5 = RATIONAL Two LONGs. The first LONG is the numerator and the second LONG expresses the // denominator.,
                     else   if  (p.Type  ==   0x5 )
                    {
                        
//  rational
                         byte [] n  =   new   byte [p.Len  /   2 ];
                        
byte [] d  =   new   byte [p.Len  /   2 ];
                        Array.Copy(p.Value, 
0 , n,  0 , p.Len  /   2 );
                        Array.Copy(p.Value, p.Len 
/   2 , d,  0 , p.Len  /   2 );
                        
uint  a  =  convertToInt32U(n);
                        
uint  b  =  convertToInt32U(d);
                        Rational r 
=   new  Rational(a, b);
                        
//
                        
// convert here
                        
//
                         switch  (p.Id)
                        {
                            
case   0x9202 //  aperture
                                v  =   " F/ "   +  Math.Round(Math.Pow(Math.Sqrt( 2 ), r.ToDouble()),  2 ).ToString();
                                
break ;
                            
case   0x920A :
                                v 
=  r.ToDouble().ToString();
                                
break ;
                            
case   0x829A :
                                v 
=  r.ToDouble().ToString();
                                
break ;
                            
case   0x829D //  F-number
                                v  =   " F/ "   +  r.ToDouble().ToString();
                                
break ;
                            
default :
                                v 
=  r.ToString( " / " );
                                
break ;
                        }

                    }
                    
// 7 = UNDEFINED An 8-bit byte that can take any value depending on the field definition,
                     else   if  (p.Type  ==   0x7 )
                    {
                        
switch  (p.Id)
                        {
                            
case   0xA300 :
                                {
                                    
if  (p.Value[ 0 ==   3 )
                                    {
                                        v 
=   " DSC " ;
                                    }
                                    
else
                                    {
                                        v 
=   " reserved " ;
                                    }
                                    
break ;
                                }
                            
case   0xA301 :
                                
if  (p.Value[ 0 ==   1 )
                                    v 
=   " A directly photographed image " ;
                                
else
                                    v 
=   " Not a directly photographed image " ;
                                
break ;
                            
default :
                                v 
=   " - " ;
                                
break ;
                        }
                    }
                    
// 9 = SLONG A 32-bit (4 -byte) signed integer (2s complement notation),
                     else   if  (p.Type  ==   0x9 )
                    {
                        v 
=  convertToInt32(p.Value).ToString();
                    }
                    
// 10 = SRATIONAL Two SLONGs. The first SLONG is the numerator and the second SLONG is the
                    
// denominator.
                     else   if  (p.Type  ==   0xA )
                    {

                        
//  rational
                         byte [] n  =   new   byte [p.Len  /   2 ];
                        
byte [] d  =   new   byte [p.Len  /   2 ];
                        Array.Copy(p.Value, 
0 , n,  0 , p.Len  /   2 );
                        Array.Copy(p.Value, p.Len 
/   2 , d,  0 , p.Len  /   2 );
                        
int  a  =  convertToInt32(n);
                        
int  b  =  convertToInt32(d);
                        Rational r 
=   new  Rational(a, b);
                        
//
                        
//  convert here
                        
//
                         switch  (p.Id)
                        {
                            
case   0x9201 //  shutter speed
                                v  =   " 1/ "   +  Math.Round(Math.Pow( 2 , r.ToDouble()),  2 ).ToString();
                                
break ;
                            
case   0x9203 :
                                v 
=  Math.Round(r.ToDouble(),  4 ).ToString();
                                
break ;
                            
default :
                                v 
=  r.ToString( " / " );
                                
break ;
                        }
                    }
                    
//  add it to the list
                     if  (properties[name]  ==   null )
                        properties.Add(name, v);
                    
//  cat it too
                    data  +=  v;
                    data 
+=   this .sp;
                }

            }

        
///   <summary>
        
///  
        
///   </summary>
        
///   <returns></returns>
         public   override   string  ToString()
        {
            
return  data;
        }
        
///   <summary>
        
///  
        
///   </summary>
        
///   <param name="arr"></param>
        
///   <returns></returns>
         int  convertToInt32( byte [] arr)
        {
            
if  (arr.Length  !=   4 )
                
return   0 ;
            
else
                
return  arr[ 3 <<   24   |  arr[ 2 <<   16   |  arr[ 1 <<   8   |  arr[ 0 ];
        }
        
///   <summary>
        
///  
        
///   </summary>
        
///   <param name="arr"></param>
        
///   <returns></returns>
         int  convertToInt16( byte [] arr)
        {
            
if  (arr.Length  !=   2 )
                
return   0 ;
            
else
                
return  arr[ 1 <<   8   |  arr[ 0 ];
        }
        
///   <summary>
        
///  
        
///   </summary>
        
///   <param name="arr"></param>
        
///   <returns></returns>
         uint  convertToInt32U( byte [] arr)
        {
            
if  (arr.Length  !=   4 )
                
return   0 ;
            
else
                
return  Convert.ToUInt32(arr[ 3 <<   24   |  arr[ 2 <<   16   |  arr[ 1 <<   8   |  arr[ 0 ]);
        }
        
///   <summary>
        
///  
        
///   </summary>
        
///   <param name="arr"></param>
        
///   <returns></returns>
         uint  convertToInt16U( byte [] arr)
        {
            
if  (arr.Length  !=   2 )
                
return   0 ;
            
else
                
return  Convert.ToUInt16(arr[ 1 <<   8   |  arr[ 0 ]);
        }
        
#region  IEnumerable Members

        
public  IEnumerator GetEnumerator()
        {
            
//  TODO:  Add EXIFextractor.GetEnumerator implementation
             return  ( new  EXIFextractorEnumerator( this .properties));
        }

        
#endregion
    }

    
//
    
//  dont touch this class. its for IEnumerator
    
//  
    
//
     class  EXIFextractorEnumerator : IEnumerator
    {
        Hashtable exifTable;
        IDictionaryEnumerator index;

        
internal  EXIFextractorEnumerator(Hashtable exif)
        {
            
this .exifTable  =  exif;
            
this .Reset();
            index 
=  exif.GetEnumerator();
        }

        
#region  IEnumerator Members

        
public   void  Reset()
        {
            
this .index  =   null ;
        }

        
public   object  Current
        {
            
get
            {
                
return  ( new  Pair( this .index.Key,  this .index.Value));
            }
        }

        
public   bool  MoveNext()
        {
            
if  (index  !=   null   &&  index.MoveNext())
                
return   true ;
            
else
                
return   false ;
        }

        
#endregion

    }
    
public   class  Pair
    {
        
public   string  First;
        
public   string  Second;
        
public  Pair( object  key,  object  value)
        {
            
this .First  =  key.ToString();
            
this .Second  =  value.ToString();
        }
    }

}

 

translation.cs

 

ExpandedBlockStart.gif translation.cs
using  System;
using  System.Collections.Generic;
using  System.Collections;
using  System.Text;

namespace  EXIF
{
    
///   <summary>
    
///  summary description for translation.
    
///   </summary>
     public   class  translation : Hashtable 
    {
        
///   <summary>
        
///  
        
///   </summary>
         public  translation()
        {
            
this .Add( 0x8769 " exif ifd " );
            
this .Add( 0x8825 " gps ifd " );
            
this .Add( 0xfe " new subfile type " );
            
this .Add( 0xff " subfile type " );
            
this .Add( 0x100 " image width " );
            
this .Add( 0x101 " image height " );
            
this .Add( 0x102 " bits per sample " );
            
this .Add( 0x103 " compression " );
            
this .Add( 0x106 " photometric interp " );
            
this .Add( 0x107 " thresh holding " );
            
this .Add( 0x108 " cell width " );
            
this .Add( 0x109 " cell height " );
            
this .Add( 0x10a " fill order " );
            
this .Add( 0x10d " document name " );
            
this .Add( 0x10e " image description " );
            
this .Add( 0x10f " equip make " );
            
this .Add( 0x110 " equip model " );
            
this .Add( 0x111 " strip offsets " );
            
this .Add( 0x112 " orientation " );
            
this .Add( 0x115 " samples perpixel " );
            
this .Add( 0x116 " rows per strip " );
            
this .Add( 0x117 " strip bytes count " );
            
this .Add( 0x118 " min sample value " );
            
this .Add( 0x119 " max sample value " );
            
this .Add( 0x11a " x resolution " );
            
this .Add( 0x11b " y resolution " );
            
this .Add( 0x11c " planar config " );
            
this .Add( 0x11d " page name " );
            
this .Add( 0x11e " x position " );
            
this .Add( 0x11f " y position " );
            
this .Add( 0x120 " free offset " );
            
this .Add( 0x121 " free byte counts " );
            
this .Add( 0x122 " gray response unit " );
            
this .Add( 0x123 " gray response curve " );
            
this .Add( 0x124 " t4 option " );
            
this .Add( 0x125 " t6 option " );
            
this .Add( 0x128 " resolution unit " );
            
this .Add( 0x129 " page number " );
            
this .Add( 0x12d " transfer funcition " );
            
this .Add( 0x131 " software used " );
            
this .Add( 0x132 " date time " );
            
this .Add( 0x13b " artist " );
            
this .Add( 0x13c " host computer " );
            
this .Add( 0x13d " predictor " );
            
this .Add( 0x13e " white point " );
            
this .Add( 0x13f " primary chromaticities " );
            
this .Add( 0x140 " colormap " );
            
this .Add( 0x141 " halftone hints " );
            
this .Add( 0x142 " tile width " );
            
this .Add( 0x143 " tile length " );
            
this .Add( 0x144 " tile offset " );
            
this .Add( 0x145 " tile bytecounts " );
            
this .Add( 0x14c " inkset " );
            
this .Add( 0x14d " ink names " );
            
this .Add( 0x14e " number of inks " );
            
this .Add( 0x150 " dot range " );
            
this .Add( 0x151 " target printer " );
            
this .Add( 0x152 " extra samples " );
            
this .Add( 0x153 " sample format " );
            
this .Add( 0x154 " s min sample value " );
            
this .Add( 0x155 " s max sample value " );
            
this .Add( 0x156 " transfer range " );
            
this .Add( 0x200 " jpeg proc " );
            
this .Add( 0x201 " jpeg interformat " );
            
this .Add( 0x202 " jpeg interlength " );
            
this .Add( 0x203 " jpeg restartinterval " );
            
this .Add( 0x205 " jpeg losslesspredictors " );
            
this .Add( 0x206 " jpeg pointtransforms " );
            
this .Add( 0x207 " jpeg qtables " );
            
this .Add( 0x208 " jpeg dctables " );
            
this .Add( 0x209 " jpeg actables " );
            
this .Add( 0x211 " ycbcr coefficients " );
            
this .Add( 0x212 " ycbcr subsampling " );
            
this .Add( 0x213 " ycbcr positioning " );
            
this .Add( 0x214 " ref black white " );
            
this .Add( 0x8773 " icc profile " );
            
this .Add( 0x301 " gamma " );
            
this .Add( 0x302 " icc profile descriptor " );
            
this .Add( 0x303 " srgb renderingintent " );
            
this .Add( 0x320 " image title " );
            
this .Add( 0x8298 " copyright " );
            
this .Add( 0x5001 " resolution x unit " );
            
this .Add( 0x5002 " resolution y unit " );
            
this .Add( 0x5003 " resolution x lengthunit " );
            
this .Add( 0x5004 " resolution y lengthunit " );
            
this .Add( 0x5005 " print flags " );
            
this .Add( 0x5006 " print flags version " );
            
this .Add( 0x5007 " print flags crop " );
            
this .Add( 0x5008 " print flags bleed width " );
            
this .Add( 0x5009 " print flags bleed width scale " );
            
this .Add( 0x500a " halftone lpi " );
            
this .Add( 0x500b " halftone lpiunit " );
            
this .Add( 0x500c " halftone degree " );
            
this .Add( 0x500d " halftone shape " );
            
this .Add( 0x500e " halftone misc " );
            
this .Add( 0x500f " halftone screen " );
            
this .Add( 0x5010 " jpeg quality " );
            
this .Add( 0x5011 " grid size " );
            
this .Add( 0x5012 " thumbnail format " );
            
this .Add( 0x5013 " thumbnail width " );
            
this .Add( 0x5014 " thumbnail height " );
            
this .Add( 0x5015 " thumbnail colordepth " );
            
this .Add( 0x5016 " thumbnail planes " );
            
this .Add( 0x5017 " thumbnail rawbytes " );
            
this .Add( 0x5018 " thumbnail size " );
            
this .Add( 0x5019 " thumbnail compressedsize " );
            
this .Add( 0x501a " color transfer function " );
            
this .Add( 0x501b " thumbnail data " );
            
this .Add( 0x5020 " thumbnail imagewidth " );
            
this .Add( 0x502 " thumbnail imageheight " );
            
this .Add( 0x5022 " thumbnail bitspersample " );
            
this .Add( 0x5023 " thumbnail compression " );
            
this .Add( 0x5024 " thumbnail photometricinterp " );
            
this .Add( 0x5025 " thumbnail imagedescription " );
            
this .Add( 0x5026 " thumbnail equipmake " );
            
this .Add( 0x5027 " thumbnail equipmodel " );
            
this .Add( 0x5028 " thumbnail stripoffsets " );
            
this .Add( 0x5029 " thumbnail orientation " );
            
this .Add( 0x502a " thumbnail samplesperpixel " );
            
this .Add( 0x502b " thumbnail rowsperstrip " );
            
this .Add( 0x502c " thumbnail stripbytescount " );
            
this .Add( 0x502d " thumbnail resolutionx " );
            
this .Add( 0x502e " thumbnail resolutiony " );
            
this .Add( 0x502f " thumbnail planarconfig " );
            
this .Add( 0x5030 " thumbnail resolutionunit " );
            
this .Add( 0x5031 " thumbnail transferfunction " );
            
this .Add( 0x5032 " thumbnail softwareused " );
            
this .Add( 0x5033 " thumbnail datetime " );
            
this .Add( 0x5034 " thumbnail artist " );
            
this .Add( 0x5035 " thumbnail whitepoint " );
            
this .Add( 0x5036 " thumbnail primarychromaticities " );
            
this .Add( 0x5037 " thumbnail ycbcrcoefficients " );
            
this .Add( 0x5038 " thumbnail ycbcrsubsampling " );
            
this .Add( 0x5039 " thumbnail ycbcrpositioning " );
            
this .Add( 0x503a " thumbnail refblackwhite " );
            
this .Add( 0x503b " thumbnail copyright " );
            
this .Add( 0x5090 " luminance table " );
            
this .Add( 0x5091 " chrominance table " );
            
this .Add( 0x5100 " frame delay " );
            
this .Add( 0x5101 " loop count " );
            
this .Add( 0x5110 " pixel unit " );
            
this .Add( 0x5111 " pixel perunit x " );
            
this .Add( 0x5112 " pixel perunit y " );
            
this .Add( 0x5113 " palette histogram " );
            
this .Add( 0x829a " exposure time " );
            
this .Add( 0x829d " f-number " );
            
this .Add( 0x8822 " exposure prog " );
            
this .Add( 0x8824 " spectral sense " );
            
this .Add( 0x8827 " iso speed " );
            
this .Add( 0x8828 " oecf " );
            
this .Add( 0x9000 " ver " );
            
this .Add( 0x9003 " dtorig " );
            
this .Add( 0x9004 " dtdigitized " );
            
this .Add( 0x9101 " compconfig " );
            
this .Add( 0x9102 " compbpp " );
            
this .Add( 0x9201 " shutter speed " );
            
this .Add( 0x9202 " aperture " );
            
this .Add( 0x9203 " brightness " );
            
this .Add( 0x9204 " exposure bias " );
            
this .Add( 0x9205 " maxaperture " );
            
this .Add( 0x9206 " subjectdist " );
            
this .Add( 0x9207 " metering mode " );
            
this .Add( 0x9208 " lightsource " );
            
this .Add( 0x9209 " flash " );
            
this .Add( 0x920a " focallength " );
            
this .Add( 0x927c " maker note " );
            
this .Add( 0x9286 " user comment " );
            
this .Add( 0x9290 " dtsubsec " );
            
this .Add( 0x9291 " dtorigss " );
            
this .Add( 0x9292 " dtdigss " );
            
this .Add( 0xa000 " fpxver " );
            
this .Add( 0xa001 " colorspace " );
            
this .Add( 0xa002 " pixxdim " );
            
this .Add( 0xa003 " pixydim " );
            
this .Add( 0xa004 " relatedwav " );
            
this .Add( 0xa005 " interop " );
            
this .Add( 0xa20b " flashenergy " );
            
this .Add( 0xa20c " spatialfr " );
            
this .Add( 0xa20e " focalxres " );
            
this .Add( 0xa20f " focalyres " );
            
this .Add( 0xa210 " focalresunit " );
            
this .Add( 0xa214 " subject loc " );
            
this .Add( 0xa215 " exposure index " );
            
this .Add( 0xa217 " sensing method " );
            
this .Add( 0xa300 " filesource " );
            
this .Add( 0xa301 " scenetype " );
            
this .Add( 0xa302 " cfapattern " );
            
this .Add( 0x0 " gps ver " );
            
this .Add( 0x1 " gps latituderef " );
            
this .Add( 0x2 " gps latitude " );
            
this .Add( 0x3 " gps longituderef " );
            
this .Add( 0x4 " gps longitude " );
            
this .Add( 0x5 " gps altituderef " );
            
this .Add( 0x6 " gps altitude " );
            
this .Add( 0x7 " gps gpstime " );
            
this .Add( 0x8 " gps gpssatellites " );
            
this .Add( 0x9 " gps gpsstatus " );
            
this .Add( 0xa " gps gpsmeasuremode " );
            
this .Add( 0xb " gps gpsdop " );
            
this .Add( 0xc " gps speedref " );
            
this .Add( 0xd " gps speed " );
            
this .Add( 0xe " gps trackref " );
            
this .Add( 0xf " gps track " );
            
this .Add( 0x10 " gps imgdirref " );
            
this .Add( 0x11 " gps imgdir " );
            
this .Add( 0x12 " gps mapdatum " );
            
this .Add( 0x13 " gps destlatref " );
            
this .Add( 0x14 " gps destlat " );
            
this .Add( 0x15 " gps destlongref " );
            
this .Add( 0x16 " gps destlong " );
            
this .Add( 0x17 " gps destbearref " );
            
this .Add( 0x18 " gps destbear " );
            
this .Add( 0x19 " gps destdistref " );
            
this .Add( 0x1a " gps destdist " );
        }
    }
    
///   <summary>
    
///  private class
    
///   </summary>
     internal   class  Rational
    {
        
private   int  n;
        
private   int  d;
        
public  Rational( int  n,  int  d)
        {
            
this .n  =  n;
            
this .d  =  d;
            simplify(
ref   this .n,  ref   this .d);
        }
        
public  Rational( uint  n,  uint  d)
        {
            
this .n  =  Convert.ToInt32(n);
            
this .d  =  Convert.ToInt32(d);

            simplify(
ref   this .n,  ref   this .d);
        }
        
public  Rational()
        {
            
this .n  =   this .d  =   0 ;
        }
        
public   string  ToString( string  sp)
        {
            
if  (sp  ==   null ) sp  =   " / " ;
            
return  n.ToString()  +  sp  +  d.ToString();
        }
        
public   double  ToDouble()
        {
            
if  (d  ==   0 )
                
return   0.0 ;

            
return  Math.Round(Convert.ToDouble(n)  /  Convert.ToDouble(d),  2 );
        }
        
private   void  simplify( ref   int  a,  ref   int  b)
        {
            
if  (a  ==   0   ||  b  ==   0 )
                
return ;

            
int  gcd  =  euclid(a, b);
            a 
/=  gcd;
            b 
/=  gcd;
        }
        
private   int  euclid( int  a,  int  b)
        {
            
if  (b  ==   0 )
                
return  a;
            
else
                
return  euclid(b, a  %  b);
        }
    }
}

 

Program.cs

 

ExpandedBlockStart.gif Program.cs
static   void  Main( string [] args)
{
    
string  strFile  =   " DSC_0170.JPG " ;
    System.Drawing.Bitmap bmp 
=   new  Bitmap(strFile);

    
//  create a new instance of Extractor 
    
//  class. Here "\n" is the newline 
    
//  that is used to seprate output of two tags. 
    
//  You can replace it with "," if you want
    EXIF.EXIFextractor er  =   new  EXIF.EXIFextractor( ref  bmp,  " \n " );

    
//  now dump all the tags on console
    Console.Write(er);

    
//  to set a tag you have to specify the tag id
    
//  code 0x13B is for artist name
    
//  since this number has ascii string with 
    
//  it pass the string you want to set
    
// er.setTag(0x13B, " http://www.goheer.com ");

    
//  dispose the image here or do whatever you want.
    bmp.Dispose();
    
    Console.ReadLine();
}

 

 整理自: http://www.codeproject.com/KB/graphics/exifextractor.aspx

转载于:https://www.cnblogs.com/yang_sq/archive/2010/05/07/1729491.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
[Serializable] public class EXIF { #region -- Class level members -- // Class level members. private Image _picture; #endregion #region -- Constructors -- // Constructors. /// <summary> /// This is default constructor of the EXIF class. /// </summary> public EXIF() { } /// <summary> /// This is base constructor of the EXIF class. /// </summary> public EXIF(string filePath) { _picture = Image.FromFile(filePath); } #endregion #region -- Public methods -- /// <summary> /// This method returns EXIF property values. /// </summary> /// <param name="exifCode">EXIF property to be returned.</param> public string GetEXIFProperty(Definitions.exifCode exifCode) { // Declare local variables. string returnValue; try { // All of the EXIF properties will return strings to display in the control. // Some of the properties require additional formatting or massaging // of the data once it is returned. Those properties have their own // methods. switch (exifCode) { case Definitions.exifCode.ImageDescription: returnValue = ParsedString(Definitions.exifCode.ImageDescription); break; case Definitions.exifCode.Make: returnValue = ParsedString(Definitions.exifCode.Make); break; case Definitions.exifCode.Model: returnValue = ParsedString(Definitions.exifCode.Model); break; case Definitions.exifCode.Orientation: returnValue = Orientation(); break; case Definitions.exifCode.XResolution: returnValue = ParseResolution(Definitions.exifCode.XResolution); break; case Definitions.exifCode.YResolution: returnValue = ParseResolution(Definitions.exifCode.YResolution); break; case Definitions.exifCode.ResolutionUnit: returnValue = ResolutionUnit(); break; case Definitions.exifCode.Software: returnValue = ParsedString(Definitions.exifCode.Software); break; case Definitions.exifCode.DateTime: returnValue = ParsedDate(Definitions.exifCode.DateTime).ToString(); break; case Definitions.exifCode.WhitePoint: returnValue = WhitePoint(); break; case Definitions.exifCode.PrimaryChromaticities: returnValue = PrimaryChromaticities(); break; case Definitions.exifCode.YCbCrCoefficients: returnValue = YCbCrCoefficients(); break; case Definitions.exifCode.YCbCrPositioning: returnValue = YCbCrPositioning(); break; case Definitions.exifCode.ReferenceBlackWhite: returnValue = ReferenceBlackWhite(); break; case Definitions.exifCode.Copyright: returnValue = ParsedString(Definitions.exifCode.Copyright); break; case Definitions.exifCode.ExposureTime: returnValue = ExposureTime(); break; case Definitions.exifCode.FNumber: returnValue = FNumber(); break; case Definitions.exifCode.ExposureProgram: returnValue = ExposureProgram(); break; case Definitions.exifCode.ISOSpeedRatings: returnValue = UnformattedShort(Definitions.exifCode.ISOSpeedRatings); break; case Definitions.exifCode.ExifVersion: returnValue = ParsedString(Definitions.exifCode.ExifVersion); break; case Definitions.exifCode.DateTimeOriginal: returnValue = ParsedDate(Definitions.exifCode.DateTimeOriginal).ToString(); break; case Definitions.exifCode.DateTimeDigitized: returnValue = ParsedDate(Definitions.exifCode.DateTimeDigitized).ToString(); break; case Definitions.exifCode.ComponentsConfiguration: returnValue = ComponentsConfiguration(); break; case Definitions.exifCode.CompressedBitsPerPixel: returnValue = CompressedBitsPerPixel(); break; case Definitions.exifCode.ShutterSpeedValue: returnValue = ShutterSpeedValue(); break; case Definitions.exifCode.ApertureValue: returnValue = ApertureValue(); break; case Definitions.exifCode.BrightnessValue: returnValue = BrightnessValue(); break; case Definitions.exifCode.ExposureBiasValue: returnValue = ExposureBiasValue(); break; case Definitions.exifCode.MaxApertureValue: returnValue = MaxApertureValue(); break; case Definitions.exifCode.SubjectDistance: returnValue = SubjectDistance(); break; case Definitions.exifCode.MeteringMode: returnValue = MeteringMode(); break; case Definitions.exifCode.LightSource: returnValue = LightSource(); break; case Definitions.exifCode.Flash: returnValue = Flash(); break; case Definitions.exifCode.FocalLength: returnValue = FocalLength(); break; case Definitions.exifCode.MakerNote: returnValue = MakerNote(); break; case Definitions.exifCode.UserComment: returnValue = ParsedString(Definitions.exifCode.UserComment); break; case Definitions.exifCode.SubsecTime: returnValue = ParsedString(Definitions.exifCode.SubsecTime); break; case Definitions.exifCode.SubsecTimeOriginal: returnValue = ParsedString(Definitions.exifCode.SubsecTimeOriginal); break; case Definitions.exifCode.SubsecTimeDigitized: returnValue = ParsedString(Definitions.exifCode.SubsecTimeDigitized); break; case Definitions.exifCode.FlashpixVersion: returnValue = ParsedString(Definitions.exifCode.FlashpixVersion); break; case Definitions.exifCode.ColorSpace: returnValue = ColorSpace(); break; case Definitions.exifCode.RelatedSoundFile: returnValue = ParsedString(Definitions.exifCode.RelatedSoundFile); break; case Definitions.exifCode.FocalPlaneXResolution: returnValue = FocalPlaneXResolution(); break; case Definitions.exifCode.FocalPlaneYResolution: returnValue = FocalPlaneYResolution(); break; case Definitions.exifCode.FocalPlaneResolutionUnit: returnValue = ResolutionUnit(); break; case Definitions.exifCode.ExposureIndex: returnValue = ExposureIndex(); break; case Definitions.exifCode.SensingMethod: returnValue = SensingMethod(); break; case Definitions.exifCode.FileSource: returnValue = FileSource(); break; case Definitions.exifCode.SceneType: returnValue = SceneType(); break; case Definitions.exifCode.CFAPattern: returnValue = ParsedString(Definitions.exifCode.CFAPattern); break; case Definitions.exifCode.InteroperabilityIndex: returnValue = ParsedString(Definitions.exifCode.InteroperabilityIndex); break; case Definitions.exifCode.ImageWidth: returnValue = UnformattedShort(Definitions.exifCode.ImageWidth); break; case Definitions.exifCode.ImageLength: returnValue = UnformattedShort(Definitions.exifCode.ImageLength); ; break; case Definitions.exifCode.BitsPerSample: returnValue = BitsPerSample(); break; case Definitions.exifCode.Compression: returnValue = Compression(); break; case Definitions.exifCode.PhotometricInterpretation: returnValue = PhotometricInterpretation(); break; case Definitions.exifCode.StripOffsets: returnValue = StripOffsets(); break; case Definitions.exifCode.SamplesPerPixel: returnValue = UnformattedShort(Definitions.exifCode.SamplesPerPixel); break; case Definitions.exifCode.RowsPerStrip: returnValue = UnformattedShort(Definitions.exifCode.RowsPerStrip); break; case Definitions.exifCode.StripByteCounts: returnValue = StripByteCounts(); break; case Definitions.exifCode.PlanarConfiguration: returnValue = PlanarConfiguration(); break; case Definitions.exifCode.YCbCrSubSampling: returnValue = YCbCrSubSampling(); break; case Definitions.exifCode.ImageUniqueID: returnValue = ParsedString(Definitions.exifCode.ImageUniqueID); break; case Definitions.exifCode.JPEGInterchangeFormatLength: returnValue = UnformattedShort(Definitions.exifCode.JPEGInterchangeFormatLength); break; case Definitions.exifCode.TransferFunction: returnValue = "Not implemented."; break; case Definitions.exifCode.PixelXDimension: returnValue = UnformattedShort(Definitions.exifCode.PixelXDimension); break; case Definitions.exifCode.PixelYDimension: returnValue = UnformattedShort(Definitions.exifCode.PixelYDimension); break; case Definitions.exifCode.SpectralSensitivity: returnValue = ParsedString(Definitions.exifCode.SpectralSensitivity); break; case Definitions.exifCode.OECF: returnValue = ParsedString(Definitions.exifCode.OECF); break; case Definitions.exifCode.CustomRendered: returnValue = CustomRendered(); break; case Definitions.exifCode.ExposureMode: returnValue = ExposureMode(); break; case Definitions.exifCode.WhiteBalance: returnValue = WhiteBalance(); break; case Definitions.exifCode.DigitalZoomRatio: returnValue = DigitalZoomRatio(); break; case Definitions.exifCode.FocalLengthIn35mmFilm: returnValue = FocalLengthIn35mmFilm(); break; case Definitions.exifCode.SceneCaptureType: returnValue = SceneCaptureType(); break; case Definitions.exifCode.GainControl: returnValue = GainControl(); break; case Definitions.exifCode.Contrast: returnValue = Contrast(); break; case Definitions.exifCode.Saturation: returnValue = Saturation(); break; case Definitions.exifCode.Sharpness: returnValue = Sharpness(); break; case Definitions.exifCode.DeviceSettingDescription: returnValue = ParsedString(Definitions.exifCode.DeviceSettingDescription); break; case Definitions.exifCode.SubjectDistanceRange: returnValue = SubjectDistanceRange(); break; default: returnValue = "EXIF property not found."; break; } return returnValue; } catch { return "N/A"; } } #endregion #region -- EXIF Methods -- /// <summary> /// This method returns the bits per sample EXIF property. /// </summary> private string BitsPerSample() { //Declare local variables. string returnValue = "EXIF property not found."; byte[] data = GetPropertyValue(Definitions.exifCode.BitsPerSample); //Translate the EXIF code into a readable value. if (!data.Equals(null)) { returnValue = data[0].ToString() + " " + data[1].ToString() + " " + data[2].ToString(); } return returnValue; } /// <summary> /// This method returns the compression EXIF property. /// </summary> private string Compression() { //Declare local variables. string returnValue = "EXIF property not found."; byte[] data = GetPropertyValue(Definitions.exifCode.Compression); //Translate the EXIF code into a readable value. if (!data.Equals(null)) { switch (data[0]) { case 1: returnValue = "uncompressed"; break; case 6: returnValue = "JPEG compression (thumbnails only)"; break; default: returnValue = "reserved"; break; } } return returnValue; } /// <summary> /// This method returns the photometric interpretation EXIF property. /// </summary> private string PhotometricInterpretation() { //Declare local variables. string returnValue = "EXIF property not found."; byte[] data = GetPropertyValue(Definitions.exifCode.PhotometricInterpretation); //Translate the EXIF code into a readable value. if (data != null) { switch (data[0]) { case 2: returnValue = "RBG"; break; case 6: returnValue = "YCbCr"; break; default: returnValue = "reserved"; break; } } return returnValue; } /// <summary> /// This method returns the strip offsets EXIF property. /// </summary> private string StripOffsets() { return "Not implemented."; } /// <summary> /// This method returns the strip byte counts EXIF property. /// </summary> private string StripByteCounts() { return "Not implemented."; } /// <summary> /// This method returns the planar configuration EXIF property. /// </summary> private string PlanarConfiguration() { //Declare local variables. string returnValue = "EXIF property not found."; byte[] data = GetPropertyValue(Definitions.exifCode.PlanarConfiguration); //Translate the EXIF code into a readable value. if (data != null) { switch (data[0]) { case 1: returnValue = "chunky format"; break; case 2: returnValue = "planar format"; break; default: returnValue = "reserved"; break; } } return returnValue; } /// <summary> /// This method returns the YCbCr subsampling EXIF property. /// </summary> private string YCbCrSubSampling() { //Declare local variables. string returnValue = "EXIF property not found."; byte[] data = GetPropertyValue(Definitions.exifCode.YCbCrSubSampling); //Translate the EXIF code into a readable value. if (data != null) { switch (data[0]) { case 2: if (data[1] == 1) { returnValue = "YCbCr4:2:2"; } else { returnValue = "YCbCr4:2:0"; } break; default: returnValue = "reserved"; break; } } return returnValue; } /// <summary> /// This method returns the orientation EXIF property. /// </summary> private string Orientation() { //Declare local variables. string returnValue = "EXIF property not found."; byte[] data = GetPropertyValue(Definitions.exifCode.Orientation); //Translate the EXIF code into a readable value. if (data.Length > 0) { switch (data[0]) { case 1: returnValue = "The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side."; break; case 2: returnValue = "The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side."; break; case 3: returnValue = "The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side."; break; case 4: returnValue = "The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side."; break; case 5: returnValue = "The 0th row is at the visual left-hand side of the image, and the 0th column is the visual top."; break; case 6: returnValue = "The 0th row is at the visual right-hand side of the image, and the 0th column is the visual top."; break; case 7: returnValue = "The 0th row is at the visual right-hand side of the image, and the 0th column is the visual bottom."; break; case 8: returnValue = "The 0th row is at the visual left-hand side of the image, and the 0th column is the visual bottom."; break; default: returnValue = "Other"; break; } } return returnValue; } /// <summary> /// This method returns the resolution unit EXIF property. /// </summary> private string ResolutionUnit() { //Declare local variables. string returnValue = "EXIF property not found."; byte[] resUnit = GetPropertyValue(Definitions.exifCode.ResolutionUnit); //Translate the EXIF code into a readable value. if (resUnit != null) { switch (resUnit[0]) { case 2: returnValue = "inches"; break; case 3: returnValue = "centimeters"; break; default: returnValue = "reserved"; break; } } return returnValue; } /// <summary> /// This method returns the white point EXIF property. /// </summary> private string WhitePoint() { string returnValue = "EXIF property not found."; EXIFRational[] data = ParsedRationalArray(Definitions.exifCode.WhitePoint); if (data.Length > 0) { returnValue = data[0].Denominator.ToString() + ", " + data[1].Denominator.ToString(); } return returnValue; } /// <summary> /// This method returns the primary chromaticities EXIF property. /// </summary> private string PrimaryChromaticities() { string returnValue = "EXIF property not found."; EXIFRational[] data = ParsedRationalArray(Definitions.exifCode.PrimaryChromaticities); if (data.Length > 0) { returnValue = data[0].Denominator.ToString() + ", " + data[1].Denominator.ToString() + ", " + data[2].Denominator.ToString() + ", " + data[3].Denominator.ToString() + ", " + data[4].Denominator.ToString() + ", " + data[5].Denominator.ToString(); } return returnValue; } /// <summary> /// This method returns the YCbCr coefficients EXIF property. /// </summary> private string YCbCrCoefficients() { string returnValue = "EXIF property not found."; EXIFRational[] data = ParsedRationalArray(Definitions.exifCode.YCbCrCoefficients); if (data.Length > 0) { returnValue = data[0].Denominator.ToString() + ", " + data[1].Denominator.ToString() + ", " + data[2].Denominator.ToString(); } return returnValue; } /// <summary> /// This method returns the YCbCr positioning EXIF property. /// </summary> private string YCbCrPositioning() { //Declare local variables. string returnValue = ""; byte[] data = GetPropertyValue(Definitions.exifCode.YCbCrPositioning); //Translate the EXIF code into a readable value. if (data.Length > 0) { switch (data[0]) { case 1: returnValue = "centered"; break; case 2: returnValue = "co-sited"; break; default: returnValue = "reserved"; break; } } else { returnValue = "EXIF property not found."; } return returnValue; } /// <summary> /// This method returns the reference black white EXIF property. /// </summary> private string ReferenceBlackWhite() { string returnValue = "EXIF property not found."; EXIFRational[] data = ParsedRationalArray(Definitions.exifCode.ReferenceBlackWhite); if (data.Length > 0) { returnValue = "[" + data[0].Denominator.ToString() + ", " + data[1].Denominator.ToString() + ", " + data[2].Denominator.ToString() + ", " + data[3].Denominator.ToString() + ", " + data[4].Denominator.ToString() + ", " + data[5].Denominator.ToString() + "]"; } return returnValue; } /// <summary> /// This method returns the exposure time EXIF property. /// </summary> private string ExposureTime() { //Declare local variables. string returnValue = "EXIF property not found."; EXIFRational exposureTime = ParsedRational(Definitions.exifCode.ExposureTime); //Translate the EXIF code into a readable value. if (!exposureTime.Equals(null)) { if (exposureTime.Numerator == 0 && exposureTime.Denominator == 0) { returnValue = "N/A"; } else { returnValue = string.Format("{0}/{1} s", exposureTime.Numerator, exposureTime.Denominator); } } else { returnValue = "N/A"; } return returnValue; } /// <summary> /// This method returns the FNumber EXIF property. /// </summary> private string FNumber() { //Declare local variables. string returnValue = "EXIF property not found."; EXIFRational fNumber = ParsedRational(Definitions.exifCode.FNumber); //Translate the EXIF code into a readable value. if (!fNumber.Equals(null)) { returnValue = string.Format("f{0}", (float)(fNumber.Numerator / fNumber.Denominator)); } return returnValue; } /// <summary> /// This method returns the exposure program EXIF property. /// </summary> private string ExposureProgram() { //Declare local variables. string returnValue = "EXIF property not found."; byte[] data = GetPropertyValue(Definitions.exifCode.ExposureProgram); //Translate the EXIF code into a readable value. if (data.Length > 0) { switch (data[0]) { case 0: returnValue = "Not defined"; break; case 1: returnValue = "Manual"; break; case 2: returnValue = "Normal program"; break; case 3: returnValue = "Aperture priority"; break; case 4: returnValue = "Shutter priority"; break; case 5: returnValue = "Creative program (biased toward depth of field)"; break; case 6: returnValue = "Action program (biased toward fast shutter speed)"; break; case 7: returnValue = "Portrait mode (for closeup photos with the background out of focus)"; break; case 8: returnValue = "Landscape mode (for landscape photos with the background in focus)"; break; default: returnValue = "Reserved"; break; } } return returnValue; } /// <summary> /// This method returns the components configuration EXIF property. /// </summary> private string ComponentsConfiguration() { //Declare local variables. string returnValue = "EXIF property not found."; byte[] data = GetPropertyValue(Definitions.exifCode.ComponentsConfiguration); switch (data[0]) { case 1: returnValue = "YCbCr"; break; case 4: returnValue = "RGB"; break; default: returnValue = "Reserved"; break; } return returnValue; } /// <summary> /// This method returns the compressed bits per pixel EXIF property. /// </summary> // This method needs to fixed to return the correct value. private string CompressedBitsPerPixel() { //Declare local variables. string returnValue = "EXIF property not found."; EXIFRational cbpp = ParsedRational(Definitions.exifCode.CompressedBitsPerPixel); //Translate the EXIF code into a readable value. if (!cbpp.Equals(null)) { returnValue = string.Format("{0}/{1}", cbpp.Numerator, cbpp.Denominator); } return returnValue; } /// <summary> /// This method returns the aperture value EXIF property. /// </summary> private string ApertureValue() { //Declare local variables. string returnValue = "EXIF property not found."; EXIFRational fNumber = ParsedRational(Definitions.exifCode.FNumber); //Translate the EXIF code into a readable value. if (!fNumber.Equals(null)) { double av = Math.Round(2 * Math.Log(((fNumber.Numerator / fNumber.Denominator)), 2.00)); returnValue = string.Format("f{0}", (double)av); } return returnValue; } /// <summary> /// This method returns the shutter speed value EXIF property. /// </summary> private string ShutterSpeedValue() { //Declare local variables. string returnValue = "EXIF property not found."; returnValue = ExposureTime(); return returnValue; } /// <summary> /// This method returns the subject distance EXIF property. /// </summary> private string SubjectDistance() { //Declare local variables. string returnValue = "EXIF property not found."; EXIFRational sd = ParsedRational(Definitions.exifCode.SubjectDistance); //Translate the EXIF code into a readable value. if (!sd.Equals(null)) { returnValue = string.Format("{0}", sd.Numerator); } return returnValue; } /// <summary> /// This method returns the metering mode EXIF property. /// </summary> private string MeteringMode() { //Declare local variables. string returnValue = "EXIF property not found."; byte[] data = GetPropertyValue(Definitions.exifCode.MeteringMode); //Translate the EXIF code into a readable value. if (data.Length > 0) { switch (data[0]) { case 0: returnValue = "Unknown"; break; case 1: returnValue = "Average"; break; case 2: returnValue = "CenterWeightedAverage"; break; case 3: returnValue = "Spot"; break; case 4: returnValue = "MultiSpot"; break; case 5: returnValue = "Pattern"; break; case 6: returnValue = "Partial"; break; case 255: returnValue = "Other"; break; default: returnValue = "Reserved"; break; } } return returnValue; } /// <summary> /// This method returns the light source EXIF property. /// </summary> private string LightSource() { //Declare local variables. string returnValue = "EXIF property not found."; byte[] data = GetPropertyValue(Definitions.exifCode.LightSource); //Translate the EXIF code into a readable value. if (data.Length > 0) { switch (data[0]) { case 1: returnValue = "Daylight"; break; case 2: returnValue = "Fluorescent"; break; case 3: returnValue = "Tungsten (incandescent light)"; break; case 4: returnValue = "Flash"; break; case 9: returnValue = "Fine weather"; break; case 10: returnValue = "Cloudy weather"; break; case 11: returnValue = "Shade"; break; case 12: returnValue = "Daylight fluorescent (D 5700 - 7100K)"; break; case 13: returnValue = "Day white fluorescent (N 4600 - 5400K)"; break; case 14: returnValue = "Cool white fluorescent (W 3900 - 4500K)"; break; case 15: returnValue = "White fluorescent (WW 3200 - 3700K)"; break; case 17: returnValue = "Standard light A"; break; case 18: returnValue = "Standard light B"; break; case 19: returnValue = "Standard light C"; break; case 20: returnValue = "D55"; break; case 21: returnValue = "D65"; break; case 22: returnValue = "D75."; break; case 23: returnValue = "D50"; break; case 24: returnValue = "ISO studio tungsten"; break; case 255: returnValue = "other light source"; break; default: returnValue = "Reserved"; break; } } return returnValue; } /// <summary> /// This method returns the flash EXIF property. /// </summary> private string Flash() { //Declare local variables. string returnValue = "EXIF property not found."; byte[] data = GetPropertyValue(Definitions.exifCode.Flash); //Translate the EXIF code into a readable value. if (data.Length > 0) { switch (data[0]) { case 0: returnValue = "Flash did not fire."; break; case 1: returnValue = "Flash fired."; break; case 5: returnValue = "Strobe return light not detected."; break; case 7: returnValue = "Strobe return light detected."; break; case 9: returnValue = "Flash fired, compulsory flash mode."; break; case 13: returnValue = "Flash fired, compulsory flash mode, return light not detected."; break; case 15: returnValue = "Flash fired, compulsory flash mode, return light detected."; break; case 16: returnValue = "Flash did not fire, compulsory flash mode."; break; case 24: returnValue = "Flash did not fire, auto mode."; break; case 25: returnValue = "Flash fired, auto mode."; break; case 29: returnValue = "Flash fired, auto mode, return light not detected."; break; case 31: returnValue = "Flash fired, auto mode, return light detected."; break; case 32: returnValue = "No flash function."; break; case 65: returnValue = "Flash fired, red-eye reduction mode."; break; case 69: returnValue = "Flash fired, red-eye reduction mode, return light not detected."; break; case 71: returnValue = "Flash fired, red-eye reduction mode, return light detected."; break; case 73: returnValue = "Flash fired, compulsory flash mode, red-eye reduction mode."; break; case 77: returnValue = "Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected."; break; case 79: returnValue = "Flash fired, compulsory flash mode, red-eye reduction mode, return light detected."; break; case 89: returnValue = "Flash fired, auto mode, red-eye reduction mode."; break; case 93: returnValue = "Flash fired, auto mode, return light not detected, red-eye reduction mode."; break; case 95: returnValue = "Flash fired, auto mode, return light detected, red-eye reduction mode."; break; default: returnValue = "Not defined, reserved."; break; } } return returnValue; } /// <summary> /// This method returns the focal length EXIF property. /// </summary> private string FocalLength() { //Declare local variables. string returnValue = "EXIF property not found."; EXIFRational focalLength = ParsedRational(Definitions.exifCode.FocalLength); //Translate the EXIF code into a readable value. if (!focalLength.Equals(null)) { if (focalLength.Numerator == 0 && focalLength.Denominator == 0) { returnValue = "N/A"; } else { returnValue = string.Format("{0:N0} mm", focalLength.Numerator * 1.0 / focalLength.Denominator); } } return returnValue; } /// <summary> /// This method returns the maker note EXIF property. /// </summary> private string MakerNote() { return "Not implemented."; } /// <summary> /// This method returns the color space EXIF property. /// </summary> private string ColorSpace() { //Declare local variables. string returnValue = "EXIF property not found."; byte[] data = GetPropertyValue(Definitions.exifCode.ColorSpace); //Translate the EXIF code into a readable value. if (data.Length > 0) { switch (data[0]) { case 1: returnValue = "sRGB"; break; case 255: returnValue = "Uncalibrated"; break; default: returnValue = "Reserved"; break; } } return returnValue; } /// <summary> /// This method returns the focal plane x resolution EXIF property. /// </summary> private string FocalPlaneXResolution() { //Declare local variables. string returnValue = "EXIF property not found."; EXIFRational focalPlaneXRes = ParsedRational(Definitions.exifCode.FocalPlaneXResolution); //Translate the EXIF code into a readable value. if (!focalPlaneXRes.Equals(null)) { returnValue = string.Format("{0:N0} mm", (focalPlaneXRes.Numerator * 1.0 / focalPlaneXRes.Denominator)); } return returnValue; } /// <summary> /// This method returns the focal plane y resolution EXIF property. /// </summary> private string FocalPlaneYResolution() { //Declare local variables. string returnValue = "EXIF property not found."; EXIFRational focalPlaneYRes = ParsedRational(Definitions.exifCode.FocalPlaneYResolution); //Translate the EXIF code into a readable value. if (!focalPlaneYRes.Equals(null)) { returnValue = string.Format("{0:N0} mm", focalPlaneYRes.Numerator * 1.0 / focalPlaneYRes.Denominator); } return returnValue; } /// <summary> /// This method returns the exposure index EXIF property. /// </summary> private string ExposureIndex() { //Declare local variables. string returnValue = "EXIF property not found."; EXIFRational expIndex = ParsedRational(Definitions.exifCode.ExposureIndex); //Translate the EXIF code into a readable value. if (!expIndex.Equals(null)) { returnValue = string.Format("{0:N0} mm", expIndex.Numerator * 1.0 / expIndex.Denominator); } return returnValue; } /// <summary> /// This method returns the sensing method EXIF property. /// </summary> private string SensingMethod() { // Declare local variables. // Get the value for this EXIF property. byte[] data = GetPropertyValue(Definitions.exifCode.SensingMethod); string returnValue = "EXIF property not found."; if (data.Length > 0) { switch (data[0]) { case 1: returnValue = "Not defined."; break; case 2: returnValue = "One-chip color area sensor."; break; case 3: returnValue = "Two-chip color area sensor."; break; case 4: returnValue = "Three-chip color area sensor."; break; case 5: returnValue = "Color sequential area sensor."; break; case 7: returnValue = "Trilinear sensor."; break; case 8: returnValue = "Color sequential linear sensor"; break; default: returnValue = "Reserved."; break; } } return returnValue; } /// <summary> /// This method returns the file source EXIF property. /// </summary> private string FileSource() { // Declare local variables. // Get the value for this EXIF property. byte[] data = GetPropertyValue(Definitions.exifCode.FileSource); string returnValue = "EXIF property not found."; if (data.Length > 0) { switch (data[0]) { case 3: returnValue = "DSC"; break; default: returnValue = "Reserved"; break; } } return returnValue; } /// <summary> /// This method returns the scene type EXIF property. /// </summary> private string SceneType() { // Declare local variables. // Get the value for this EXIF property. byte[] data = GetPropertyValue(Definitions.exifCode.FileSource); string returnValue = "EXIF property not found."; if (data.Length > 0) { switch (data[0]) { case 1: returnValue = "A directly photographed image."; break; default: returnValue = "Reserved."; break; } } return returnValue; } /// <summary> /// This method returns the custom rendered EXIF property. /// </summary> private string CustomRendered() { // Declare local variables. // Get the value for this EXIF property. byte[] data = GetPropertyValue(Definitions.exifCode.CustomRendered); string returnValue = "EXIF property not found."; if (data.Length > 0) { switch (data[0]) { case 0: returnValue = "Normal process"; break; case 1: returnValue = "Custom process"; break; default: returnValue = "Reserved"; break; } } return returnValue; } /// <summary> /// This method returns the exposure mode EXIF property. /// </summary> private string ExposureMode() { // Declare local variables. // Get the value for this EXIF property. byte[] data = GetPropertyValue(Definitions.exifCode.ExposureMode); string returnValue = "EXIF property not found."; if (data.Length > 0) { switch (data[0]) { case 0: returnValue = "Auto exposure"; break; case 1: returnValue = "Manual exposure"; break; case 2: returnValue = "Auto bracket"; break; default: returnValue = "Reserved"; break; } } return returnValue; } /// <summary> /// This method returns the white balance EXIF property. /// </summary> private string WhiteBalance() { // Declare local variables. // Get the value for this EXIF property. byte[] data = GetPropertyValue(Definitions.exifCode.WhiteBalance); string returnValue = "EXIF property not found."; if (data.Length > 0) { switch (data[0]) { case 0: returnValue = "Auto white balance"; break; case 1: returnValue = "Manual white balance"; break; default: returnValue = "Reserved"; break; } } return returnValue; } /// <summary> /// This method returns the focal length in 35mm film EXIF property. /// </summary> private string FocalLengthIn35mmFilm() { // Declare local variables. // Get the value for this EXIF property. byte[] data = GetPropertyValue(Definitions.exifCode.FocalLengthIn35mmFilm); string returnValue = "EXIF property not found."; if (data.Length > 0) { if (data[0] == 0) { returnValue = "Unknown"; } else if (data[0].ToString().Trim() == "NaN") { returnValue = "N/A"; } else { returnValue = data[0].ToString() + "mm"; } } return returnValue; } /// <summary> /// This method returns the scene capture type EXIF property. /// </summary> private string SceneCaptureType() { // Declare local variables. // Get the value for this EXIF property. byte[] data = GetPropertyValue(Definitions.exifCode.SceneCaptureType); string returnValue = "EXIF property not found."; if (data.Length > 0) { switch (data[0]) { case 0: returnValue = "Standard"; break; case 1: returnValue = "Landscape"; break; case 2: returnValue = "Portrait"; break; case 3: returnValue = "Night scene"; break; default: returnValue = "Reserved"; break; } } return returnValue; } /// <summary> /// This method returns the gain control EXIF property. /// </summary> private string GainControl() { // Declare local variables. // Get the value for this EXIF property. byte[] data = GetPropertyValue(Definitions.exifCode.GainControl); string returnValue = "EXIF property not found."; if (data.Length > 0) { switch (data[0]) { case 0: returnValue = "None"; break; case 1: returnValue = "Low gain up"; break; case 2: returnValue = "High gain up"; break; case 3: returnValue = "Low gain down"; break; case 4: returnValue = "High gain down"; break; default: returnValue = "Reserved"; break; } } return returnValue; } /// <summary> /// This method returns the contrast EXIF property. /// </summary> private string Contrast() { // Declare local variables. // Get the value for this EXIF property. byte[] data = GetPropertyValue(Definitions.exifCode.Contrast); string returnValue = "EXIF property not found."; if (data.Length > 0) { switch (data[0]) { case 0: returnValue = "Normal"; break; case 1: returnValue = "Soft"; break; case 2: returnValue = "Hard"; break; default: returnValue = "Reserved"; break; } } return returnValue; } /// <summary> /// This method returns the saturation EXIF property. /// </summary> private string Saturation() { // Declare local variables. // Get the value for this EXIF property. byte[] data = GetPropertyValue(Definitions.exifCode.Saturation); string returnValue = "EXIF property not found."; if (data.Length > 0) { switch (data[0]) { case 0: returnValue = "Normal"; break; case 1: returnValue = "Low saturation"; break; case 2: returnValue = "High saturation"; break; default: returnValue = "Reserved"; break; } } return returnValue; } /// <summary> /// This method returns the sharpness EXIF property. /// </summary> private string Sharpness() { // Declare local variables. // Get the value for this EXIF property. byte[] data = GetPropertyValue(Definitions.exifCode.Sharpness); string returnValue = "EXIF property not found."; if (data.Length > 0) { switch (data[0]) { case 0: returnValue = "Normal"; break; case 1: returnValue = "Soft"; break; case 2: returnValue = "Hard"; break; default: returnValue = "Reserved"; break; } } return returnValue; } /// <summary> /// This method returns the subject distance range EXIF property. /// </summary> private string SubjectDistanceRange() { // Declare local variables. // Get the value for this EXIF property. byte[] data = GetPropertyValue(Definitions.exifCode.SubjectDistanceRange); string returnValue = "EXIF property not found."; if (data.Length > 0) { switch (data[0]) { case 0: returnValue = "Unknown"; break; case 1: returnValue = "Macro"; break; case 2: returnValue = "Close view"; break; case 3: returnValue = "Distant view"; break; default: returnValue = "Reserved"; break; } } return returnValue; } /// <summary> /// This method returns the subject location EXIF property. /// </summary> private string SubjectLocation() { // Declare local variables. // Get the value for this EXIF property. byte[] data = GetPropertyValue(Definitions.exifCode.SubjectLocation); string returnValue = "EXIF property not found."; if (data.Length > 0) { returnValue = "(" + data[0].ToString() + ", " + data[1].ToString() + ")"; } return returnValue; } /// <summary> /// This method returns the digital zoom ratio EXIF property. /// </summary> private string DigitalZoomRatio() { //Declare local variables. string returnValue = "EXIF property not found."; EXIFRational dzr = ParsedRational(Definitions.exifCode.DigitalZoomRatio); //Translate the EXIF code into a readable value. if (!dzr.Equals(null)) { returnValue = dzr.Numerator.ToString() + ":" + dzr.Denominator.ToString(); } return returnValue; } /// <summary> /// This method returns the brightness value EXIF property. /// </summary> private string BrightnessValue() { //Declare local variables. string returnValue = "EXIF property not found."; EXIFRational data = ParsedRational(Definitions.exifCode.DigitalZoomRatio); //Translate the EXIF code into a readable value. if (!data.Equals(null)) { if ((long)data.Numerator >= Int32.MaxValue) { returnValue = "Unknown"; } else { returnValue = Math.Log(data.Numerator / data.Denominator, 2.0).ToString(); } } return returnValue; } /// <summary> /// This method returns the max aperture value EXIF property. /// </summary> private string MaxApertureValue() { //Declare local variables. string returnValue = "EXIF property not found."; EXIFRational data = ParsedRational(Definitions.exifCode.MaxApertureValue); //Translate the EXIF code into a readable value. if (!data.Equals(null)) { returnValue = string.Format("f{0}", (double)(data.Numerator / data.Denominator)); } return returnValue; } /// <summary> /// This method returns the exposure bias value EXIF property. /// </summary> private string ExposureBiasValue() { //Declare local variables. string returnValue = "EXIF property not found."; EXIFRational data = ParsedRational(Definitions.exifCode.ExposureBiasValue); //Translate the EXIF code into a readable value. if (!data.Equals(null)) { returnValue = string.Format("f{0}", (double)(data.Numerator / data.Denominator)); } return returnValue; } #endregion #region -- Private helper functions -- // Private helper functions. /// <summary> /// This method retrieves the data from the propery items collection. /// </summary> private byte[] GetPropertyValue(Definitions.exifCode exifCode) { return _picture.GetPropertyItem((int)exifCode).Value; } /// <summary> /// This method returns string EXIF data. /// </summary> private string ParsedString(Definitions.exifCode exifCode) { // Declare local variables. // Retrieve the data for this EXIF property. byte[] data = GetPropertyValue(exifCode); // Holds the return value. string parsed = ""; // If there's data, go ahead and parse it. if (data.Length > 1) { // Allocate some memory. IntPtr h = Marshal.AllocHGlobal(data.Length); int i = 0; foreach (byte b in data) { Marshal.WriteByte(h, i, b); i++; } parsed = Marshal.PtrToStringAnsi(h); Marshal.FreeHGlobal(h); } return parsed; } /// <summary> /// This method returns rational EXIF data. /// </summary> private EXIFRational ParsedRational(Definitions.exifCode exifCode) { // Declare local variables. // Retrieve the data for this EXIF property. byte[] data = GetPropertyValue(exifCode); // Parse the data. EXIFRational parsed = new EXIFRational(data); return parsed; } /// <summary> /// This method returns an array of rational EXIF data. /// </summary> private EXIFRational[] ParsedRationalArray(Definitions.exifCode exifCode) { // Declare local variables. // Retrieve the data for this EXIF property. byte[] data = GetPropertyValue(exifCode); // Holds the return value. EXIFRational[] parsed = null; int arraySize = (data.Length / 8); if (arraySize > 0) { parsed = new EXIFRational[arraySize]; for (int i = 0; i < arraySize; i++) { parsed[i] = new EXIFRational(data, i * 8); } } return parsed; } /// <summary> /// This method returns date/time EXIF data. /// </summary> private DateTime ParsedDate(Definitions.exifCode exifCode) { // Declare local variables. // Create a new date object. DateTime ret = new DateTime(1900, 1, 1, 0, 0, 0); // Parse the data. string date = ParsedString(exifCode); // Format the data. if (date.Length >= 19) {
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值