/// /// Returns the n-th picture's EXIF-Data /// public static EXIFModel GetEXIF(int pictureId) { SqlCommand command = DbHelper.CreateCommand("SELECT * FROM EXIF WHERE PictureID = @Id"); command.Parameters.AddWithValue("@Id", pictureId); SqlDataReader reader = command.ExecuteReader(); if (!reader.HasRows) { reader.Close(); Log.Information("EXIF-data for Picture with Id {pictureId} does not exist.", pictureId); return(null); } reader.Read(); int i = 0; EXIFModel exif = new EXIFModel() { PictureId = (int)reader[i++], DateAndTime = reader[i++] is DBNull ? null : (DateTime?)reader[i - 1], Orientation = reader[i++] is DBNull ? null : (int?)reader[i - 1], FocalLength = new Tuple <float?, float?>( reader[i++] is DBNull ? null : (float?)reader[i - 1], reader[i++] is DBNull ? null : (float?)reader[i - 1]), FNumber = reader[i++] is DBNull ? null : (float?)reader[i - 1], Exposure = reader[i++] is DBNull ? null : reader[i - 1].ToString(), Iso = reader[i++] is DBNull ? null : (int?)reader[i - 1] }; reader.Close(); return(exif); }
public PictureModel(string fileName) { _fileName = fileName; _iptc = new IPTCModel(); _exif = new EXIFModel(); _camera = new CameraModel("", ""); }
public EXIFViewModel(EXIFModel core_model) { _exposureProgram = core_model.ExposureProgram; _ISOValues = core_model.ISOValue; Console.WriteLine("{0},{1}", core_model.ISOValue, _ISOValues); _make = core_model.Make; _exposureTime = core_model.ExposureTime; _flash = core_model.Flash; _fNumber = core_model.FNumber; }
private IEXIFModel GetDemoExif() { EXIFModel e = new EXIFModel(); e.Make = "Make"; e.FNumber = 1; e.ExposureTime = 5; e.ISOValue = 200; e.Flash = true; e.ExposureProgram = ExposurePrograms.LandscapeMode; return(e); }
public EXIFViewModel(EXIFModel emdl) { exifMdl = emdl; /*ExposureProgram = emdl.ExposureProgram.ToString(); * //ExposureProgramResource * ExposureTime = emdl.ExposureTime; * Flash = emdl.Flash; * FNumber = emdl.FNumber; * //ISORating * //ISORatingResource * ISOValue = emdl.ISOValue; * Make = emdl.Make;*/ }
public PictureViewModel(PictureModel mdl) { this.mdl = mdl; _camera = new CameraViewModel(); _iptc = new IPTCViewModel(); EXIFModel em = new EXIFModel(); em.Make = "Hi"; em.ISOValue = 30; em.Flash = true; _exif = new EXIFViewModel(em); _picTitle = ""; _photographer = new PhotographerViewModel(new PhotographerModel()); }
/// <summary> /// Extracts EXIF information from a picture. NOTE: You may simulate the action. /// </summary> /// <param name="filename"></param> /// <returns></returns> public IEXIFModel ExtractEXIF(string filename) { var exifData = new EXIFModel(); IEnumerable <string> pathFiles = Directory.EnumerateFiles(GlobalInformation.Path); if (!pathFiles.Contains(Path.Combine(GlobalInformation.Path, filename))) { throw new FileNotFoundException(); } exifData.ExposureProgram = ExposurePrograms.CreativeProgram; exifData.ExposureTime = 10; exifData.FNumber = 2; exifData.Flash = true; exifData.ISOValue = 8008; exifData.Make = "Make"; return(exifData); }
public MockDAL() { //Fake Pictures FakePictures.Add(new PictureModel()); FakePictures.Add(new PictureModel()); FakePictures.Add(new PictureModel()); FakePictures[0].ID = 1234; FakePictures[0].FileName = "Blume.jpg"; FakePictures[1].ID = 2; FakePictures[2].ID = 3; //Fake Photographers FakePhotographers.Add(new PhotographerModel()); FakePhotographers.Add(new PhotographerModel()); FakePhotographers.Add(new PhotographerModel()); FakePhotographers[0].ID = 1234; FakePhotographers[1].ID = 2; FakePhotographers[2].ID = 3; //Fake Cameras FakeCameras.Add(new CameraModel()); FakeCameras.Add(new CameraModel()); FakeCameras.Add(new CameraModel()); FakeCameras[0].ID = 1234; FakeCameras[1].ID = 2; FakeCameras[2].ID = 3; //Fake EXIF EXIFModel exmdl = new EXIFModel(); exmdl.ExposureProgram = ExposurePrograms.Manual; exmdl.ExposureTime = 1000; exmdl.Flash = false; exmdl.FNumber = 10; exmdl.ISOValue = 200; exmdl.Make = "Blubb"; FakePictures[1].FileName = "Img1.jpg"; FakePictures[1].EXIF = exmdl; }
//TODO: Bericht erstellen Liste Tags mit jeweils Anzahl Bilder //TODO: Bild drucken mit IPTC, EXIF Informationen (wenn vorhanden, auch Photograph) // ReSharper disable once InconsistentNaming public static IEXIFModel ExtractEXIF(string filename) { try { var filePath = Path.Combine(Constants.PicPath, filename); Console.WriteLine(filePath); if (!File.Exists(filePath)) { throw new FileNotFoundException(); } using (Image image = new Bitmap(filePath)) { var propItems = image.PropertyItems; //const int MODEL = 0x0110; const int MAKE = 0x010f; const int FNUMBER = 0x9202; const int EXPTIME = 0x829a; const int ISOVALUE = 0x8827; const int FLASH = 0x9209; int[] flashInfo = { 0x0, 0x8, 0x10, 0x14, 0x18, 0x20, 0x30, 0x50, 0x58 }; var exif = new EXIFModel(); foreach (var prop in propItems) { switch (prop.Id) { /*case MODEL: * { * var encoding = new ASCIIEncoding(); * exif.Make = (encoding.GetString(prop.Value)).TrimEnd('\0'); * break; * }*/ case FNUMBER: { exif.FNumber = (decimal) BitConverter.ToUInt32(prop.Value, 0) / BitConverter.ToUInt32(prop.Value, 4); break; } case EXPTIME: { exif.ExposureTime = (decimal) BitConverter.ToUInt32(prop.Value, 0) / BitConverter.ToUInt32(prop.Value, 4); break; } case ISOVALUE: { exif.ISOValue = BitConverter.ToInt16(prop.Value, 0); break; } case FLASH: { exif.Flash = !flashInfo.Contains(BitConverter.ToUInt16(prop.Value, 0)); break; } default: break; case MAKE: { var encoding = new ASCIIEncoding(); exif.Make = (encoding.GetString(prop.Value)).TrimEnd('\0'); break; } } } return(exif); } } catch (Exception e) { Console.WriteLine(e); throw; } }