title: Cropping an image from file and resaving in C#
body: <p>Never really worked with Graphics before. I have looked around on this and pieced together a few solutions from answers which address small parts of my question. but none have worked.</p>
  
  <p>I want to load an image from a file, which will always be 320x240 in size. I then want to crop it to obtain a 240x240 image, with the outer 40px on each side trimmed. After this is done I want to save as a new image.</p>
  
  <pre><code>    private void croptoSquare(string date)
      {
          //Location of 320x240 image
          string fileName = Server.MapPath("~/Content/images/" + date + "contactimage.jpg");
  
          //New rectangle of final size (I think maybe Point is where I would eventually specify where the crop square site i.e. (40, 0))
          Rectangle cropRect = new Rectangle(new Point(0, 0), new Size(240, 240));
          //Create a Bitmap with correct height/width.
          Bitmap target = new Bitmap(cropRect.Width, cropRect.Height);
  
          //Load image from file
          using (Image image = Image.FromFile(fileName))
          {
              //Create Graphics object from image
              using (Graphics graphic = Graphics.FromImage(image))
              {
                  //Not sure what this does, I found it on a post.
                  graphic.DrawImage(image, 
                      cropRect, 
                      new Rectangle(0, 0, target.Width, target.Height),
                      GraphicsUnit.Pixel);
  
                  fileName = Server.MapPath("~/Content/images/" + date + "contactimagecropped.jpg");
                  image.Save(fileName);
              }
  
          }
      }
  </code></pre>
  
  <p>Currently it is simply resaving the same image and I'm not sure why. I have specified a destination rectangle as 240x240 and a src rectangle as 320x240.</p>
  
  <p>As I say I know basically nothing about working with graphics objects so I imagine this is blatant.</p>
  
  <p>Can anybody tell me how to achieve what I want?</p>