title: Set DPI value to Tiff Image in C#
body: <p>I'm trying to set dpi value of a <code>TIFF</code> Image in C# through code but somehow the values are not persisted after saving the Image.</p>
  
  <pre><code>using (var image = new Bitmap(@"c:\newimage.tif"))
  {
      uint[] uintArray = { 300, 1}; //Setting DPI as 300
      byte[] bothArray = ConvertUintArrayToByteArray(uintArray);
      PropertyItem item = image.PropertyItems.Where(p =&gt; p.Id == 0x11A).Single();
      var val = BitConverter.ToUInt32(item.Value, 0);
      Console.WriteLine(val);
      item.Id = 0x11A;
      item.Value = bothArray;
      item.Type = 5;
      item.Len = item.Value.Length;
      image.SetPropertyItem(item);
      image.Save(@"c:\newimage1.tif"); //Save image to new File
  }
  </code></pre>
  
  <p>What is wrong with this code? Any kind of help would be appreciated.
  <a href="http://www.atalasoft.com/docs/dotimage/docs/TIFFTags.html" rel="nofollow noreferrer">TIFF file tag definitions</a></p>