locked
How To Write A Keyword To JPEG RRS feed

  • Question

  • Im using Windows XP and VS2005.

    What i want to be able to do is write a value out to the Keywords field for the jpeg file i have loaded in my PictureBox

     

     

    Monday, May 28, 2007 6:13 AM

Answers

  • The PropertyItem ID of Keywords tag is 40094, you can set its value in the following way:

    Code Snippet

     
             private void button1_Click(object sender, EventArgs e)

            {

               Image img = Bitmap.FromFile(@"c:\pic\1.jpg");

     

               System.Drawing.Imaging.PropertyItem propTemp = img.GetPropertyItem(40094);// Keywords

               byte[] Value = System.Text.ASCIIEncoding.Unicode.GetBytes("some key here.");                        

               propTemp.Len = Value.Length;

               propTemp.Value = Value;

               img.SetPropertyItem(propTemp);

     

               img.Save(@"c:\test1.jpg");

            }

     

    Monday, June 4, 2007 4:04 AM