//F/5,6 public ActionResult UploadFakeExif() { List<photo> _photos; using (var db2 = new photoshareEntities()) { _photos = db2.photos.ToList(); } foreach (photo p in _photos) { if (p.id == 347 || p.id == 350) { } else { exif_data _exif = new exif_data { aperture = "F/" + new Random().Next(3, 22).ToString(), camera = "Nikon D7000", date_taken = DateTime.Now.AddYears(-2). AddDays(new Random().Next(1, 360)).ToLongDateString(), focal_length = new Random().Next(18, 300).ToString(), iso = new Random().Next(100, 1600).ToString(), shutter_speed = "1/" + new Random().Next(1, 4000).ToString(), photo_id = p.id }; db.exif_data.Add(_exif); db.SaveChanges(); } } return RedirectToAction("Index"); }
/// <summary> /// Reads the exif data of the image /// </summary> /// <param name="file">The image file</param> /// <returns>exif_data object</returns> private exif_data GetImageExifData(string file) { Goheer.EXIF.EXIFextractor exif = new Goheer.EXIF.EXIFextractor(file, "", ""); exif_data exifData = new exif_data(); try { foreach (System.Web.UI.Pair s in exif) { switch (s.First.ToString().ToLower()) { case "aperture": exifData.aperture = s.Second.ToString(); break; case "f-number": exifData.aperture = s.Second.ToString(); break; case "shutter speed": exifData.shutter_speed = s.Second.ToString(); break; case "equip model": exifData.camera = s.Second.ToString(); break; case "iso speed": exifData.iso = s.Second.ToString(); break; case "date time": exifData.date_taken = s.Second.ToString(); break; case "focallength": exifData.focal_length = s.Second.ToString(); break; default: break; } } } catch { } return exifData; }