/// <summary> /// Extracts and caches the metadata for an image. /// </summary> /// <param name="pictureFileInfo">The FileInfo to the image.</param> /// <returns>The MetaData for the image.</returns> internal static Metadata GetImageData(FileInfo pictureFileInfo) { try { string cacheKey = "data(" + pictureFileInfo.FullName + ")"; Cache cache = HttpContext.Current.Cache; object cached = cache[cacheKey]; if (cached == null) { Metadata data = new Metadata(); ExifReader exif = new ExifReader(pictureFileInfo); exif.Extract(data); IptcReader iptc = new IptcReader(pictureFileInfo); iptc.Extract(data); JpegReader jpeg = new JpegReader(pictureFileInfo); jpeg.Extract(data); cache.Insert(cacheKey, data, new CacheDependency(pictureFileInfo.FullName)); return(data); } return((Metadata)cached); } catch { return(new Metadata()); } }
public IAttributeReader CreateFromSegments(FileInfo file, IEnumerable <JpegSegment> segments) { var exifReader = new ExifReader(); foreach (var segment in segments) { if (IsExifSegment(segment)) { var directories = exifReader.Extract(new ByteArrayReader(segment.Bytes, ExifHeader.Length)); return(new ExifAttributeReader(new ExifMetadata(segment, directories), _tags)); } } return(new ExifAttributeReader(new ExifMetadata(null, null), _tags)); }