title: How to resize Image File to asked file size without changing its width and height?
body: <p>How can I change an image file size to desired size ? Like an image of 800KB into 100KB ?</p>
  
  <p>I have an image of 3MB Dimensions: (2560 X 1600) with 300 dpi and bit depth of 24. I simply read it in Bitmap change its resolution to 150 dpi and save with new name with thinking that may reduce it to almost half of its original but the new file keeps same size and dpi SetResolution donot create any effect.</p>
  
  <pre><code>Bitmap image = Bitmap.FromFile("myPic.jpeg");
  image.SetResolution(96, 96);
  image.Save("newPic.jpeg");
  </code></pre>
  
  <p>Then I used this code</p>
  
  <pre><code>// Reads Image
  Bitmap image = Bitmap.FromFile("myPic.jpeg");
  
  // Sets canvas with new dpi but same dimensions and color depth
  Bitmap canvas = new Bitmap(image.Width, image.Height, PixelFormat.Format24bppRgb);
  canvas.SetResolution(150, 150);
  
  // Draw image on canvas through graphics
  Graphics graphics = Graphics.FromImage(canvas);
  graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
  graphics.DrawImage(image, new Rectangle(0, 0, image.Width, image.Height),
              new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
  
  // Saved Image
  bitmap.Save("newPic.jpeg");
  </code></pre>
  
  <p>Here dpi got changed for new file but file size jumps to 7.84MB</p>
  
  <p>Where is the fault? Does dpi have any effect on file size ?</p>
  
  <p>Thank you for your consideration.
  Stay Blessed</p>