コード例 #1
0
        public void RetrieveMetadatas()
        {
            commonMetadatas = new Molecule.Collections.Dictionary<string,string>();

            // Loading all meta data
            com.drew.metadata.Metadata photoMedatas = com.drew.imaging.jpg.JpegMetadataReader.ReadMetadata(jpegFileInfo);

            if (photoMedatas.ContainsDirectory( typeof(com.drew.metadata.exif.ExifDirectory)))
            {

                // Make
                AbstractDirectory exifDirectory =  photoMedatas.GetDirectory(typeof(com.drew.metadata.exif.ExifDirectory).ToString());
                if( exifDirectory.ContainsTag(com.drew.metadata.exif.ExifDirectory.TAG_MAKE))
                {
                    commonMetadatas.Add(exifDirectory.GetTagName(com.drew.metadata.exif.ExifDirectory.TAG_MAKE),
                                        exifDirectory.GetString( com.drew.metadata.exif.ExifDirectory.TAG_MAKE));
                }

                // Model
                if( exifDirectory.ContainsTag(com.drew.metadata.exif.ExifDirectory.TAG_MODEL))
                {
                    commonMetadatas.Add(exifDirectory.GetTagName(com.drew.metadata.exif.ExifDirectory.TAG_MODEL),
                                        exifDirectory.GetString( com.drew.metadata.exif.ExifDirectory.TAG_MODEL));
                }

                // Model
                if( exifDirectory.ContainsTag(com.drew.metadata.exif.ExifDirectory.TAG_APERTURE))
                {
                    commonMetadatas.Add(exifDirectory.GetTagName(com.drew.metadata.exif.ExifDirectory.TAG_APERTURE),
                                        exifDirectory.GetDescription( com.drew.metadata.exif.ExifDirectory.TAG_APERTURE));
                }

                if( exifDirectory.ContainsTag(com.drew.metadata.exif.ExifDirectory.TAG_FLASH))
                {
                    commonMetadatas.Add(exifDirectory.GetTagName(com.drew.metadata.exif.ExifDirectory.TAG_FLASH),
                                        exifDirectory.GetDescription( com.drew.metadata.exif.ExifDirectory.TAG_FLASH));
                }

                if( exifDirectory.ContainsTag(com.drew.metadata.exif.ExifDirectory.TAG_ISO_EQUIVALENT))
                {
                    commonMetadatas.Add(exifDirectory.GetTagName(com.drew.metadata.exif.ExifDirectory.TAG_ISO_EQUIVALENT),
                                        exifDirectory.GetString( com.drew.metadata.exif.ExifDirectory.TAG_ISO_EQUIVALENT));
                }

                if( exifDirectory.ContainsTag(com.drew.metadata.exif.ExifDirectory.TAG_FOCAL_LENGTH))
                {
                    commonMetadatas.Add(exifDirectory.GetTagName(com.drew.metadata.exif.ExifDirectory.TAG_FOCAL_LENGTH),
                                        exifDirectory.GetString( com.drew.metadata.exif.ExifDirectory.TAG_FOCAL_LENGTH));
                }

                if( exifDirectory.ContainsTag(com.drew.metadata.exif.ExifDirectory.TAG_FOCAL_LENGTH_IN_35MM_FILM))
                {
                    commonMetadatas.Add(exifDirectory.GetTagName(com.drew.metadata.exif.ExifDirectory.TAG_FOCAL_LENGTH_IN_35MM_FILM),
                                        exifDirectory.GetString( com.drew.metadata.exif.ExifDirectory.TAG_FOCAL_LENGTH_IN_35MM_FILM));
                }
            }
            if (photoMedatas.ContainsDirectory( typeof(com.drew.metadata.exif.GpsDirectory)))
            {
                AbstractDirectory gpsDirectory =  photoMedatas.GetDirectory(typeof(com.drew.metadata.exif.GpsDirectory).ToString());
                if( gpsDirectory.ContainsTag(com.drew.metadata.exif.GpsDirectory.TAG_GPS_LATITUDE) &&
                   gpsDirectory.ContainsTag(com.drew.metadata.exif.GpsDirectory.TAG_GPS_LONGITUDE))
                {
                    Rational[] latitudeRationals = gpsDirectory.GetRationalArray(com.drew.metadata.exif.GpsDirectory.TAG_GPS_LATITUDE);

                    this.ContainsGPSInformation = true;

                    this.Latitude =
                        (gpsDirectory.GetString( com.drew.metadata.exif.GpsDirectory.TAG_GPS_LONGITUDE_REF).Equals("N")? -1 : 1	)*
                        ConvertDMSToDecimalDegrees(latitudeRationals[0].DoubleValue(),
                                               latitudeRationals[1].DoubleValue(),
                                               latitudeRationals[2].DoubleValue());

                    Rational[] longitudeRationals = gpsDirectory.GetRationalArray(com.drew.metadata.exif.GpsDirectory.TAG_GPS_LONGITUDE);
                    this.Longitude =
                        (gpsDirectory.GetString( com.drew.metadata.exif.GpsDirectory.TAG_GPS_LONGITUDE_REF).Equals("W")? -1 : 1	)*
                        ConvertDMSToDecimalDegrees(longitudeRationals[0].DoubleValue(),
                                                               longitudeRationals[1].DoubleValue(),
                                                               longitudeRationals[2].DoubleValue());

                }
            }
        }
コード例 #2
0
        private void getMetadatas()
        {
            JpegMetadataReader  jpegMetadatas =  new JpegMetadataReader(new Uri(uri).LocalPath);
            jpegMetadatas.RetrieveMetadatas();

            metadatas = new Molecule.Collections.Dictionary<string, string>();
            foreach(KeyValuePair<string, string> kvp in jpegMetadatas.CommonMetadatas)
            {
                metadatas.Add(kvp.Key, kvp.Value);
            }

            if( jpegMetadatas.ContainsGPSInformation )
            {
                this.latitude = jpegMetadatas.Latitude;
                this.longitude = jpegMetadatas.Longitude;
            }
        }
コード例 #3
0
 public Photo()
 {
     this.Id = "photo" + photoIdBase++;
     this.random = new Random(this.Id.GetHashCode());
     this.description = fakeText.Substring(random.Next(50), 10 + random.Next(fakeText.Length - 60));
     Date = DateTime.Today - TimeSpan.FromDays(random.Next(180));
     Metadatas = new Molecule.Collections.Dictionary<string, string>();
     Metadatas["Name"] = Id + ".jpg";
     Metadatas["Exposure"] = "f/2.8 1/100 sec.";
     Metadatas["Size"] = "2592x1944";
     Metadatas["Camera"] = "Canone PaweurShote";
     int r = random.Next(nbJpg);
     string virtualPath = @"stublibrary\photo"+r+".jpg";
     MediaFilePath = @"C:\Users\timaniac\Projets\molecule\Molecule.MvcWebSite\atomes\photos\"+virtualPath;
     //Latitude="48.1181" Longitude="-1.6707"
     r = random.Next(2);
     if (r == 0)
     {
         Latitude = null;
         Longitude = null;
     }
     else
     {
         Latitude = 48.1181 + random.NextDouble() * 2 - 1;
         Longitude = -1.6707 + random.NextDouble() * 2 - 1;
     }
 }