/// <summary> /// Extracts aMetadata from a SegmentReader /// </summary> /// <param name="aSegmentReader">where to extract aMetadata</param> /// <returns>the aMetadata found</returns> private static Metadata ExtractJpegSegmentReaderMetadata(JpegSegmentReader aSegmentReader) { Metadata lcMetadata = new Metadata(); try { byte[] lcExifSegment = aSegmentReader.ReadSegment(JpegSegmentReader.SEGMENT_APP1); new ExifReader(lcExifSegment).Extract(lcMetadata); } catch (Exception e) { Trace.TraceWarning("Error in reading Exif segment (" + e.Message + ")"); // in the interests of catching as much data as possible, continue } try { byte[] lcIptcSegment = aSegmentReader.ReadSegment(JpegSegmentReader.SEGMENT_APPD); new IptcReader(lcIptcSegment).Extract(lcMetadata); } catch (Exception e) { Trace.TraceWarning("Error in reading Iptc segment (" + e.Message + ")"); } try { byte[] lcJpegSegment = aSegmentReader.ReadSegment(JpegSegmentReader.SEGMENT_SOF0); new JpegReader(lcJpegSegment).Extract(lcMetadata); } catch (Exception e) { Trace.TraceWarning("Error in reading Jpeg segment (" + e.Message + ")"); } try { byte[] lcJpegCommentSegment = aSegmentReader.ReadSegment(JpegSegmentReader.SEGMENT_COM); new JpegCommentReader(lcJpegCommentSegment).Extract(lcMetadata); } catch (Exception e) { Trace.TraceWarning("Error in reading Jpeg Comment segment (" + e.Message + ")"); } return(lcMetadata); }
/// <summary> /// Extracts aMetadata from a SegmentReader /// </summary> /// <param name="aSegmentReader">where to extract aMetadata</param> /// <returns>the aMetadata found</returns> private static Metadata ExtractJpegSegmentReaderMetadata(JpegSegmentReader aSegmentReader) { Metadata lcMetadata = new Metadata(); try { byte[] lcExifSegment = aSegmentReader.ReadSegment(JpegSegmentReader.SEGMENT_APP1); new ExifReader(lcExifSegment).Extract(lcMetadata); } catch (Exception e) { Trace.TraceWarning("Error in reading Exif segment ("+e.Message+")"); // in the interests of catching as much data as possible, continue } try { byte[] lcIptcSegment = aSegmentReader.ReadSegment(JpegSegmentReader.SEGMENT_APPD); new IptcReader(lcIptcSegment).Extract(lcMetadata); } catch (Exception e) { Trace.TraceWarning("Error in reading Iptc segment (" + e.Message + ")"); } try { byte[] lcJpegSegment = aSegmentReader.ReadSegment(JpegSegmentReader.SEGMENT_SOF0); new JpegReader(lcJpegSegment).Extract(lcMetadata); } catch (Exception e) { Trace.TraceWarning("Error in reading Jpeg segment (" + e.Message + ")"); } try { byte[] lcJpegCommentSegment = aSegmentReader.ReadSegment(JpegSegmentReader.SEGMENT_COM); new JpegCommentReader(lcJpegCommentSegment).Extract(lcMetadata); } catch (Exception e) { Trace.TraceWarning("Error in reading Jpeg Comment segment (" + e.Message + ")"); } return lcMetadata; }
/// <summary> /// Reads MetaData from a aFile /// </summary> /// <param name="aFile">where to read information</param> /// <returns>the aMetadata object</returns> public static Metadata ReadMetadata(FileInfo aFile) { JpegSegmentReader lcSegmentReader = null; Metadata lcMetadata = null; try { lcSegmentReader = new JpegSegmentReader(aFile); lcMetadata = JpegMetadataReader.ExtractJpegSegmentReaderMetadata(lcSegmentReader); } finally { if (lcSegmentReader != null) { // Dispose will call close for this class lcSegmentReader.Dispose(); } } return(lcMetadata); }
/// <summary> /// Reads MetaData from a aFile /// </summary> /// <param name="aFile">where to read information</param> /// <returns>the aMetadata object</returns> public static Metadata ReadMetadata(FileInfo aFile) { JpegSegmentReader lcSegmentReader = null; Metadata lcMetadata = null; try { lcSegmentReader = new JpegSegmentReader(aFile); lcMetadata = JpegMetadataReader.ExtractJpegSegmentReaderMetadata(lcSegmentReader); } finally { if (lcSegmentReader != null) { // Dispose will call close for this class lcSegmentReader.Dispose(); } } return lcMetadata; }