Exemple #1
0
        private void ReadAPP13Segment(ushort length)
        {
            var data            = ReadBlock(length);
            var iptc_iim_length = IPTC_IIM_IDENTIFIER.Length;

            if (length < iptc_iim_length || data.Mid(0, iptc_iim_length) != IPTC_IIM_IDENTIFIER)
            {
                return;
            }
            var headerInfoLen = data.Mid(iptc_iim_length, 1).ToUShort();
            int lenToSkip;

            if (headerInfoLen > 0)
            {
                lenToSkip = 1 + headerInfoLen + 4;
            }
            else
            {
                lenToSkip = 6;
            }
            data.RemoveRange(0, iptc_iim_length + lenToSkip);
            var reader = new IIM.IIMReader(data);
            var tag    = reader.Process();

            if (tag != null)
            {
                ImageTag.AddTag(tag);
            }
        }
Exemple #2
0
        /// <summary>
        ///    Reads an APP13 segment to find IPTC-IIM metadata.
        /// </summary>
        /// <param name="length">
        ///    The length of the segment that will be read.
        /// </param>
        /// <remarks>More info and specs for IPTC-IIM:
        /// - Guidelines for Handling Image Metadata (http://www.metadataworkinggroup.org/specs/)
        /// - IPTC Standard Photo Metadata (July 2010) (http://www.iptc.org/std/photometadata/specification/IPTC-PhotoMetadata-201007_1.pdf)
        /// - Extracting IPTC header information from JPEG images (http://www.codeproject.com/KB/graphics/iptc.aspx?fid=2301&amp;df=90&amp;mpp=25&amp;noise=3&amp;prof=False&amp;sort=Position&amp;view=Quick&amp;fr=51#xx0xx)
        /// - Reading IPTC APP14 Segment Header Information from JPEG Images (http://www.codeproject.com/KB/graphics/ReadingIPTCAPP14.aspx?q=iptc)
        /// </remarks>
        private void ReadAPP13Segment(ushort length)
        {
            // TODO: if both IPTC-IIM and XMP metadata is contained in a file, we should read
            // a IPTC-IIM checksum and compare that with the checksum built over the IIM block.
            // Depending on the result we should prefer the information from XMP or IIM.
            // Right now we always prefer XMP.

            var data = ReadBlock(length);

            // The APP13 segment consists of:
            // - the string "Photoshop 3.0\u0000"
            // - followed by "8BIM"
            // - and then the section type "\u0004\u0004".
            // There might be multiple 8BIM sections with different types, but we're following
            // YAGNI for now and only deal with the one we're interested in (and hope that it's
            // the first one).
            var iptc_iim_length = IPTC_IIM_IDENTIFIER.Length;

            if (length < iptc_iim_length || data.Mid(0, iptc_iim_length) != IPTC_IIM_IDENTIFIER)
            {
                return;
            }

            // PS6 introduced a new header with variable length text
            var headerInfoLen = data.Mid(iptc_iim_length, 1).ToUShort();
            int lenToSkip;

            if (headerInfoLen > 0)
            {
                // PS6 header: 1 byte headerinfolen + headerinfo + 2 bytes 00 padding (?) + 2 bytes length
                lenToSkip = 1 + headerInfoLen + 4;
            }
            else
            {
                //old style: 4 bytes 00 padding (?) + 2 bytes length
                lenToSkip = 6;
            }
            data.RemoveRange(0, iptc_iim_length + lenToSkip);

            var reader = new IIM.IIMReader(data);
            var tag    = reader.Process();

            if (tag != null)
            {
                ImageTag.AddTag(tag);
            }
        }
Exemple #3
0
        /// <summary>
        ///    Reads an APP13 segment to find IPTC-IIM metadata.
        /// </summary>
        /// <param name="length">
        ///    The length of the segment that will be read.
        /// </param>
        /// <remarks>More info and specs for IPTC-IIM:
        /// - Guidelines for Handling Image Metadata (http://www.metadataworkinggroup.org/specs/)
        /// - IPTC Standard Photo Metadata (July 2010) (http://www.iptc.org/std/photometadata/specification/IPTC-PhotoMetadata-201007_1.pdf)
        /// - Extracting IPTC header information from JPEG images (http://www.codeproject.com/KB/graphics/iptc.aspx?fid=2301&amp;df=90&amp;mpp=25&amp;noise=3&amp;prof=False&amp;sort=Position&amp;view=Quick&amp;fr=51#xx0xx)
        /// - Reading IPTC APP14 Segment Header Information from JPEG Images (http://www.codeproject.com/KB/graphics/ReadingIPTCAPP14.aspx?q=iptc)
        /// </remarks>
        void ReadAPP13Segment(ushort length)
        {
            var data = ReadBlock(length);

            // The APP13 segment consists of:
            // - the string "Photoshop 3.0\u0000"
            // - followed by "8BIM"
            // - and then the section type "\u0004\u0004".
            // There might be multiple 8BIM sections with different types, but we're following
            // YAGNI for now and only deal with the one we're interested in (and hope that it's
            // the first one).
            var iptc_iim_length = IPTC_IIM_IDENTIFIER.Length;

            if (length < iptc_iim_length || data.Mid(0, iptc_iim_length) != IPTC_IIM_IDENTIFIER)
            {
                return;
            }

            // PS6 introduced a new header with variable length text
            var headerInfoLen = data.Mid(iptc_iim_length, 1).ToUShort();
            int lenToSkip;

            if (headerInfoLen > 0)
            {
                // PS6 header: 1 byte headerinfolen + headerinfo + 2 bytes 00 padding (?) + 2 bytes length
                lenToSkip = 1 + headerInfoLen + 4;
            }
            else
            {
                //old style: 4 bytes 00 padding (?) + 2 bytes length
                lenToSkip = 6;
            }
            data.RemoveRange(0, iptc_iim_length + lenToSkip);

            var reader = new IIM.IIMReader(data);
            var tag    = reader.Process();

            if (tag != null)
            {
                ImageTag.AddTag(tag);
            }
        }
Exemple #4
0
		/// <summary>
		///    Reads an APP13 segment to find IPTC-IIM metadata.
		/// </summary>
		/// <param name="length">
		///    The length of the segment that will be read.
		/// </param>
		/// <remarks>More info and specs for IPTC-IIM:
		/// - Guidelines for Handling Image Metadata (http://www.metadataworkinggroup.org/specs/)
		/// - IPTC Standard Photo Metadata (July 2010) (http://www.iptc.org/std/photometadata/specification/IPTC-PhotoMetadata-201007_1.pdf)
		/// - Extracting IPTC header information from JPEG images (http://www.codeproject.com/KB/graphics/iptc.aspx?fid=2301&df=90&mpp=25&noise=3&prof=False&sort=Position&view=Quick&fr=51#xx0xx)
		/// - Reading IPTC APP14 Segment Header Information from JPEG Images (http://www.codeproject.com/KB/graphics/ReadingIPTCAPP14.aspx?q=iptc)
		/// </remarks>
		private void ReadAPP13Segment (ushort length)
		{
			// TODO: if both IPTC-IIM and XMP metadata is contained in a file, we should read
			// a IPTC-IIM checksum and compare that with the checksum built over the IIM block.
			// Depending on the result we should prefer the information from XMP or IIM.
			// Right now we always prefer XMP.

			var data = ReadBlock (length);

			// The APP13 segment consists of:
			// - the string "Photoshop 3.0\u0000"
			// - followed by "8BIM"
			// - and then the section type "\u0004\u0004".
			// There might be multiple 8BIM sections with different types, but we're following
			// YAGNI for now and only deal with the one we're interested in (and hope that it's
			// the first one).
			var iptc_iim_length = IPTC_IIM_IDENTIFIER.Length;
			if (length < iptc_iim_length || data.Mid (0, iptc_iim_length) != IPTC_IIM_IDENTIFIER)
				return;

			// PS6 introduced a new header with variable length text
			var headerInfoLen = data.Mid (iptc_iim_length, 1).ToUShort();
			int lenToSkip;
			if (headerInfoLen > 0) {
				// PS6 header: 1 byte headerinfolen + headerinfo + 2 bytes 00 padding (?) + 2 bytes length
				lenToSkip = 1 + headerInfoLen + 4;
			} else {
				//old style: 4 bytes 00 padding (?) + 2 bytes length
				lenToSkip = 6;
			}
			data.RemoveRange (0, iptc_iim_length + lenToSkip);

			var reader = new IIM.IIMReader (data);
			var tag = reader.Process ();
			if (tag != null)
				ImageTag.AddTag (tag);
		}