title: ASP.NET MVC3 resizing images for user profile
body: <p>I want to create user profile with image. That user can upload his photo, in his profile there would be this photo and in forum there would be small image created from original photo. I have no problem with showing image but with resizing. I have this code in controller where user can change his information (name, age, ...) and can upload photo:</p>
  
  <pre><code>[HttpPost, ValidateInput(false)]
  public ActionResult Upravit(int id, FormCollection collection, HttpPostedFileBase file)
  {
      try
      {
          var user = repo.Retrieve(id);
  
          if (TryUpdateModel(user))
          {
              if (file.ContentLength &gt; 0)
              {
                  var fileName = Path.GetFileName(file.FileName);
                  var path = Path.Combine(Server.MapPath("~/Fotky/Profilove/"), (user.Name.Name + " " + user.Name.Surname + Path.GetExtension(fileName)));
                  file.SaveAs(path);
                  user.ImagePath = "/Fotky/Profilove/" + user.Name.Name + " " + user.Name.Surname + Path.GetExtension(fileName);
  
              }
              repo.Save(user);
              return RedirectToAction("Index");
          }
          return View();
      }
      catch
      {
          return View();
      }
  }
  </code></pre>
  
  <p>and my view looks like this:</p>
  
  <pre><code>@using (Html.BeginForm("Upravit", "Uzivatel", FormMethod.Post, new { enctype = "multipart/form-data" }))
  {
      @Html.ValidationSummary(true)
      &lt;fieldset&gt;
          &lt;legend&gt;User&lt;/legend&gt;
          @Html.HiddenFor(model =&gt; model.UserID)
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.UserName)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.UserName)
              @Html.ValidationMessageFor(model =&gt; model.UserName)
          &lt;/div&gt;
          .
          .
          &lt;input type="file" name="file" id="file" /&gt;
          &lt;p&gt;
              &lt;input type="submit" value="Save" /&gt;
          &lt;/p&gt;
      &lt;/fieldset&gt;
  }
  </code></pre>
  
  <p>As I said I just need help with adding code to controller which create small image from original and save it to. Thanks for any help</p>