예제 #1
0
		protected override void PullImageProperties ()
		{
			DirectoryEntry e;
			Header header = new Header (Stream);

			e = header.Directory.Lookup (TagId.ExifIfdPointer);
			if (e != null) {
				ImageDirectory exif = ((SubdirectoryEntry)e).Directory [0];
				AddTiffDirectoryProperties (this, exif);
			}

			e = header.Directory.Lookup (TagId.SubIFDs);
			if (e != null) {
				ImageDirectory [] dirs = ((SubdirectoryEntry)e).Directory;
				 
				foreach (ImageDirectory subdir in dirs)
					AddTiffDirectoryProperties (this, subdir);
			}

			// we filter ifd0 last so that we pick up the
			// width and height from the full resolution
			// version if it exists 
			 
			AddTiffDirectoryProperties (this, header.Directory);
		}
예제 #2
0
 protected void LoadBlocks()
 {
     using (System.IO.Stream file = Open()) {
         mrm = new MrmBlock(file);
         try {
             foreach (Block b in mrm.Blocks)
             {
                 if (b is TtwBlock)
                 {
                     TtwBlock ttw = (TtwBlock)b;
                     header = ttw.TiffHeader;
                     //Header.Dump ("TTW:");
                     break;
                 }
             }
         } catch (System.Exception e) {
             //System.Console.WriteLine (e.ToString ());
         }
     }
 }
예제 #3
0
		protected void LoadBlocks () 
		{
			using (System.IO.Stream file = Open ()) {
				mrm = new MrmBlock (file);
				try {
					foreach (Block b in mrm.Blocks) {
						if (b is TtwBlock) {
							TtwBlock ttw = (TtwBlock) b;
							header = ttw.TiffHeader;
							//Header.Dump ("TTW:");
							break;
						}
					}
				} catch (System.Exception e) {
					//System.Console.WriteLine (e.ToString ());
				}
			}
		}
예제 #4
0
	public FSpot.Tiff.Header GetExifHeader ()
	{
		string name = ExifSignature.Name;
		Marker marker = FindMarker (ExifSignature);

		if (marker == null)
			return null;
		
		using (System.IO.Stream exifstream = new System.IO.MemoryStream (marker.Data, name.Length, marker.Data.Length - name.Length, false)) {
			FSpot.Tiff.Header exif = new FSpot.Tiff.Header (exifstream);
			return exif;
		}
	}
예제 #5
0
        private void AddExifProperties(JpegHeader header)
        {
            Tiff.Header ifd = header.GetExifHeader();
            if (ifd == null)
            {
                return;
            }
            //ifd.Dump ("foo"); // Uncomment to debug

            string str;

            Tiff.DirectoryEntry entry;

            // Add IFD 0 properies

            str = GetExifString(ifd.Directory, Tiff.TagId.Model);
            AddProperty(Beagle.Property.New("exif:Model", str));

            str = GetExifString(ifd.Directory, Tiff.TagId.ImageDescription);
            AddProperty(Beagle.Property.New("exif:ImageDescription", str));

            try {
                entry = ifd.Directory.Lookup(Tiff.TagId.DateTime);
                if (entry != null)
                {
                    // Assume datetime stored in the images are local times
                    AddProperty(Beagle.Property.NewDate("exif:DateTime", entry.ValueAsDate.ToUniversalTime()));
                }
            } catch (FormatException) {
                Logger.Log.Debug("EXIF DateTime '{0}' is invalid.", GetExifString(ifd.Directory, Tiff.TagId.DateTime));
            } catch (ArgumentOutOfRangeException) {
                Logger.Log.Debug("EXIF DateTime '{0}' is invalid.", GetExifString(ifd.Directory, Tiff.TagId.DateTime));
            }

            str = GetExifString(ifd.Directory, Tiff.TagId.Copyright);
            AddProperty(Beagle.Property.New("dc:rights", str));

            // Add IFD 1 properties

            Tiff.SubdirectoryEntry subdir = (Tiff.SubdirectoryEntry)ifd.Directory.Lookup(Tiff.TagId.ExifIfdPointer);
            if (subdir == null)
            {
                return;
            }

            Tiff.ImageDirectory exif = subdir.Directory [0];
            if (exif == null)
            {
                return;
            }

            entry = exif.Lookup(Tiff.TagId.UserComment);
            if (entry != null)
            {
                AddProperty(Beagle.Property.New("exif:UserComment", entry.UserCommentValue));
            }

            uint val = 0;

            entry = exif.Lookup(Tiff.TagId.PixelXDimension);
            if (entry != null)
            {
                val = entry.ValueAsLong [0];
            }
            if (val > 0)
            {
                Width = (int)val;
                AddProperty(Beagle.Property.NewUnsearched("exif:PixelXDimension", val));
            }

            val   = 0;
            entry = exif.Lookup(Tiff.TagId.PixelYDimension);
            if (entry != null)
            {
                val = entry.ValueAsLong [0];
            }
            if (val > 0)
            {
                Height = (int)val;
                AddProperty(Beagle.Property.NewUnsearched("exif:PixelYDimension", val));
            }

            str = GetExifString(exif, Tiff.TagId.ISOSpeedRatings);
            AddProperty(Beagle.Property.NewUnsearched("exif:ISOSpeedRatings", str));

            str = GetExifString(exif, Tiff.TagId.ShutterSpeedValue);
            AddProperty(Beagle.Property.NewUnsearched("exif:ShutterSpeedValue", str));

            str = GetExifString(exif, Tiff.TagId.ExposureTime);
            if (!String.IsNullOrEmpty(str))
            {
                AddProperty(Beagle.Property.NewUnsearched("exif:ExposureTime", str + " sec."));
            }

            double rational_val;

            rational_val = GetExifRational(exif, Tiff.TagId.FNumber);
            if (rational_val > 0)
            {
                AddProperty(Beagle.Property.NewUnsearched("exif:FNumber", String.Format("f/{0}", rational_val)));
            }

            rational_val = GetExifRational(exif, Tiff.TagId.ApertureValue);
            if (rational_val > 0)
            {
                AddProperty(Beagle.Property.NewUnsearched("exif:ApertureValue", rational_val));
            }

            rational_val = GetExifRational(exif, Tiff.TagId.FocalLength);
            if (rational_val > 0)
            {
                AddProperty(Beagle.Property.NewUnsearched("exif:FocalLength", String.Format("{0} mm", rational_val)));
            }

            entry = exif.Lookup(Tiff.TagId.Flash);
            if (entry != null)
            {
                ushort flash = entry.ShortValue [0];
                AddProperty(Beagle.Property.NewUnsearched("exif:Flash", GetFlashString(flash)));
            }
        }