title: A Generic error occurred in GDI+ from picture of Ipad Air
body: <p>Hi I have this error when a try to upload a picture downloaded via email from an Ipad Air Camera(JPG)</p>
  
  <p><strong>A Generic error occurred in GDI+</strong></p>
  
  <p>Here is the code, anyone can helps me? All the pictures are saving good except from this Ipad Air.</p>
  
  <pre><code>                var pic = System.Web.HttpContext.Current.Request.Files[0];// canvi per Vendor/fileuploadmaster
                  Bitmap bmp = new Bitmap(pic.InputStream);
                  DateTime dtaken;
                  PropertyItem propItem;
  
                  try {
  
                  propItem = bmp.GetPropertyItem(36867);
                  string sdate = System.Text.Encoding.UTF8.GetString(propItem.Value).Trim();
                  string secondhalf = sdate.Substring(sdate.IndexOf(" "), (sdate.Length - sdate.IndexOf(" ")));
                  string firsthalf = sdate.Substring(0, 10);
                  firsthalf = firsthalf.Replace(":", "-");
                  sdate = firsthalf + secondhalf;
                  dtaken = DateTime.Parse(sdate);
  
                  }
                  catch {
  
                  dtaken = DateTime.Now;
  
                  }
  
  
                  //Fecha de última modificacion
                  //PropertyItem propItem = bmp.GetPropertyItem(306);
  
  
                  var newFilePath = ConfigurationManager.AppSettings["PathTmpPhotos"].ToString();
  
                  var FechaString = dtaken.ToString("yyMMddHHmmss");
  
                  var newFileName = DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + visitBrandId.ToString("D10") + "_" + FechaString + "_" + pic.FileName;
                  var tmpFilePath = newFilePath + newFileName;
  
                  pic.SaveAs(tmpFilePath);
  
                  var img = FileUtilities.ResizePhoto(newFilePath, newFileName, 800, 600);
  
                  ImageCodecInfo jpgEncoder = GetEncoder(ImageFormat.Jpeg);
  
                  // Create an Encoder object based on the GUID
                  // for the Quality parameter category.
                  Encoder myEncoder = Encoder.Quality;
  
                  // Create an EncoderParameters object.
                  // An EncoderParameters object has an array of EncoderParameter
                  // objects. In this case, there is only one
                  // EncoderParameter object in the array.
                  EncoderParameters myEncoderParameters = new EncoderParameters(1);
  
                  // 0L = NO Quality // 100L = High Quality
                  EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 100L);
                  myEncoderParameters.Param[0] = myEncoderParameter;
  
                  img.Save(Path.Combine(newFilePath, newFileName), jpgEncoder, myEncoderParameters);
                  //img.Save(Path.Combine(newFilePath, newFileName));
  </code></pre>