Esempio n. 1
0
        private static string GetExifString(Tiff.ImageDirectory directory, Tiff.TagId id)
        {
            if (directory == null)
            {
                return(null);
            }

            Tiff.DirectoryEntry entry = directory.Lookup(id);
            if (entry == null)
            {
                return(null);
            }

            return(entry.ValueAsString [0]);
        }
Esempio n. 2
0
        private static double GetExifRational(Tiff.ImageDirectory directory, Tiff.TagId id)
        {
            if (directory == null)
            {
                return(0);
            }

            Tiff.DirectoryEntry entry = directory.Lookup(id);
            if (entry == null)
            {
                return(-1);
            }

            return(entry.RationalValue [0].Value);
        }
Esempio n. 3
0
		public ImageLoader (ImageDirectory directory) 
		{
			width = directory.Lookup (TagId.ImageWidth).ValueAsLong [0];
			length = directory.Lookup (TagId.ImageLength).ValueAsLong [0];
			bps = directory.Lookup (TagId.BitsPerSample).ValueAsLong;
			
			compression = (Compression) directory.Lookup (TagId.Compression).ValueAsLong [0];
			interpretation = (PhotometricInterpretation) directory.Lookup (TagId.PhotometricInterpretation).ValueAsLong [0];
			
			offsets = directory.Lookup (TagId.StripOffsets).ValueAsLong;
			strip_byte_counts = directory.Lookup (TagId.StripByteCounts).ValueAsLong;
			rows_per_strip = directory.Lookup (TagId.RowsPerStrip).ValueAsLong [0];

			if (interpretation != 
		}
Esempio n. 4
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)));
            }
        }