public static void SetExifProperties(this ExifMetadata.Metadata metadata) { string full = string.Empty; Type type = typeof(ExifMetadata.Metadata); foreach (FieldInfo prop in type.GetFields()) { string value = string.Empty; string caption = prop.Name.ToCaption() ?? prop.Name; switch (prop.Name) { case nameof(ExifMetadata.Metadata.ImageDimensions): value = metadata.ImageDimensionsAsString(); break; case nameof(ExifMetadata.Metadata.Resolution): value = metadata.ResolutionAsString(); break; case nameof(ExifMetadata.Metadata.Location): GUIPropertyManager.SetProperty("#pictures.exif.location.latitude", string.Empty); GUIPropertyManager.SetProperty("#pictures.exif.location.longitude", string.Empty); if (metadata.Location != null) { string latitude = metadata.Location.Latitude.ToLatitudeString() ?? string.Empty; string longitude = metadata.Location.Longitude.ToLongitudeString() ?? string.Empty; if (!string.IsNullOrEmpty(latitude) && !string.IsNullOrEmpty(longitude)) { value = latitude + " / " + longitude; GUIPropertyManager.SetProperty("#pictures.exif.location.latitude", metadata.Location.Latitude.ToMapString()); GUIPropertyManager.SetProperty("#pictures.exif.location.longitude", metadata.Location.Longitude.ToMapString()); } } break; case nameof(ExifMetadata.Metadata.Altitude): if (metadata.Location != null) { value = metadata.Altitude.ToAltitudeString(); } break; case nameof(ExifMetadata.Metadata.HDR): GUIPropertyManager.SetProperty("#pictures.exif.is" + prop.Name.ToLower(), metadata.HDR ? "true" : "false"); continue; default: value = ((ExifMetadata.MetadataItem)prop.GetValue(metadata)).DisplayValue ?? string.Empty; break; } if (!string.IsNullOrEmpty(value)) { value = value.ToValue() ?? value; full = full + caption + ": " + value + "\n"; } GUIPropertyManager.SetProperty("#pictures.exif." + prop.Name.ToLower(), value); } GUIPropertyManager.SetProperty("#pictures.exif.full", full); GUIPropertyManager.SetProperty("#pictures.haveexif", metadata.IsEmpty() ? "false" : "true"); }
private bool GetExifDetails(string strPicture, ref int iRotation, ref string strDateTaken) { using (ExifMetadata extractor = new ExifMetadata()) { ExifMetadata.Metadata metaData = extractor.GetExifMetadata(strPicture); try { string picExifDate = metaData.DatePictureTaken.DisplayValue; if (!String.IsNullOrEmpty(picExifDate)) // If the image contains a valid exif date store it in the database, otherwise use the file date { DateTime dat; DateTime.TryParseExact(picExifDate, "G", Thread.CurrentThread.CurrentCulture, DateTimeStyles.None, out dat); strDateTaken = dat.ToString("yyyy-MM-dd HH:mm:ss"); if (_useExif) { iRotation = EXIFOrientationToRotation(Convert.ToInt32(metaData.Orientation.Hex)); } return(true); } } catch (FormatException ex) { Log.Error("PictureDatabaseSqlLite: Exif date conversion exception err:{0} stack:{1}", ex.Message, ex.StackTrace); } } return(false); }
private void Update() { if (m_pTexture != null) { m_pTexture.Dispose(); } SetLabel(lblCameraModel, string.Empty); SetLabel(lblDateTakenLabel, string.Empty); SetLabel(lblEquipmentMake, string.Empty); SetLabel(lblExposureCompensation, string.Empty); SetLabel(lblExposureTime, string.Empty); SetLabel(lblFlash, string.Empty); SetLabel(lblFstop, string.Empty); SetLabel(lblImgDimensions, string.Empty); SetLabel(lblImgTitle, string.Empty); SetLabel(lblMeteringMode, string.Empty); SetLabel(lblResolutions, string.Empty); SetLabel(lblShutterSpeed, string.Empty); SetLabel(lblViewComments, string.Empty); if (!File.Exists(FileName)) { GUIPropertyManager.SetProperty("#selectedthumb", string.Empty); return; } int iRotate = PictureDatabase.GetRotation(FileName); m_pTexture = Util.Picture.Load(FileName, iRotate, (int)Thumbs.LargeThumbSize.uhd, (int)Thumbs.LargeThumbSize.uhd, true, false, out m_iTextureWidth, out m_iTextureHeight); ExifMetadata.Metadata metaData = PictureDatabase.GetExifFromDB(FileName); if (metaData.IsEmpty()) { metaData = PictureDatabase.GetExifFromFile(FileName); } if (!metaData.IsEmpty()) { SetLabel(lblCameraModel, metaData.CameraModel.DisplayValue); SetLabel(lblDateTakenLabel, metaData.DatePictureTaken.DisplayValue); SetLabel(lblEquipmentMake, metaData.EquipmentMake.DisplayValue); SetLabel(lblExposureCompensation, metaData.ExposureCompensation.DisplayValue); SetLabel(lblExposureTime, metaData.ExposureTime.DisplayValue); SetLabel(lblFlash, metaData.Flash.DisplayValue, true); SetLabel(lblFstop, metaData.Fstop.DisplayValue); SetLabel(lblImgDimensions, metaData.ImageDimensionsAsString()); SetLabel(lblImgTitle, Path.GetFileNameWithoutExtension(FileName)); SetLabel(lblMeteringMode, metaData.MeteringMode.DisplayValue, true); SetLabel(lblResolutions, metaData.ResolutionAsString()); SetLabel(lblShutterSpeed, metaData.ShutterSpeed.DisplayValue); SetLabel(lblViewComments, metaData.ViewerComments.DisplayValue); imgPicture.IsVisible = false; } metaData.SetExifProperties(); GUIPropertyManager.SetProperty("#selectedthumb", FileName); }
public static string ToShortString(this ExifMetadata.Metadata metadata) { string exifoutline = string.Empty; exifoutline = exifoutline + (!string.IsNullOrEmpty(metadata.EquipmentMake.DisplayValue) ? metadata.EquipmentMake.DisplayValue + " " : string.Empty); exifoutline = exifoutline + (!string.IsNullOrEmpty(metadata.CameraModel.DisplayValue) ? metadata.CameraModel.DisplayValue + " " : string.Empty); exifoutline = exifoutline + (!string.IsNullOrEmpty(metadata.ViewerComments.DisplayValue) ? metadata.ViewerComments.DisplayValue + " " : string.Empty); return(exifoutline); }
private void Update() { if (m_pTexture != null) { m_pTexture.Dispose(); } int iRotate = PictureDatabase.GetRotation(FileName); m_pTexture = Util.Picture.Load(FileName, iRotate, 1024, 1024, true, false, out m_iTextureWidth, out m_iTextureHeight); lblCameraModel.Label = string.Empty; lblDateTakenLabel.Label = string.Empty; lblEquipmentMake.Label = string.Empty; lblExposureCompensation.Label = string.Empty; lblExposureTime.Label = string.Empty; lblFlash.Label = string.Empty; lblFstop.Label = string.Empty; lblImgDimensions.Label = string.Empty; lblImgTitle.Label = string.Empty; lblMeteringMode.Label = string.Empty; lblResolutions.Label = string.Empty; lblShutterSpeed.Label = string.Empty; lblViewComments.Label = string.Empty; using (ExifMetadata extractor = new ExifMetadata()) { ExifMetadata.Metadata metaData = extractor.GetExifMetadata(FileName); lblCameraModel.Label = metaData.CameraModel.DisplayValue; lblDateTakenLabel.Label = metaData.DatePictureTaken.DisplayValue; lblEquipmentMake.Label = metaData.EquipmentMake.DisplayValue; lblExposureCompensation.Label = metaData.ExposureCompensation.DisplayValue; lblExposureTime.Label = metaData.ExposureTime.DisplayValue; lblFlash.Label = metaData.Flash.DisplayValue; lblFstop.Label = metaData.Fstop.DisplayValue; lblImgDimensions.Label = metaData.ImageDimensions.DisplayValue; lblImgTitle.Label = Path.GetFileNameWithoutExtension(FileName); lblMeteringMode.Label = metaData.MeteringMode.DisplayValue; lblResolutions.Label = metaData.Resolution.DisplayValue; lblShutterSpeed.Label = metaData.ShutterSpeed.DisplayValue; lblViewComments.Label = metaData.ViewerComments.DisplayValue; imgPicture.IsVisible = false; } if (File.Exists(FileName)) { GUIPropertyManager.SetProperty("#selectedthumb", FileName); } else { GUIPropertyManager.SetProperty("#selectedthumb", string.Empty); } }
public static string ToString(this ExifMetadata.Metadata metadata) { string full = string.Empty; Type type = typeof(ExifMetadata.Metadata); foreach (FieldInfo prop in type.GetFields()) { string value = string.Empty; string caption = prop.Name.ToCaption() ?? prop.Name; switch (prop.Name) { case nameof(ExifMetadata.Metadata.ImageDimensions): value = metadata.ImageDimensionsAsString(); break; case nameof(ExifMetadata.Metadata.Resolution): value = metadata.ResolutionAsString(); break; case nameof(ExifMetadata.Metadata.Location): if (metadata.Location != null) { string latitude = metadata.Location.Latitude.ToLatitudeString() ?? string.Empty; string longitude = metadata.Location.Longitude.ToLongitudeString() ?? string.Empty; if (!string.IsNullOrEmpty(latitude) && !string.IsNullOrEmpty(longitude)) { value = latitude + " / " + longitude; } } break; case nameof(ExifMetadata.Metadata.Altitude): if (metadata.Location != null) { value = metadata.Altitude.ToAltitudeString(); } break; case nameof(ExifMetadata.Metadata.HDR): continue; default: value = ((ExifMetadata.MetadataItem)prop.GetValue(metadata)).DisplayValue ?? string.Empty; break; } if (!string.IsNullOrEmpty(value)) { value = value.ToValue() ?? value; full = full + caption + ": " + value + "\n"; } } return(full); }
public DateTime GetDateTaken(string strPicture) { string strSQL = ""; try { string strPic = strPicture; DatabaseUtility.RemoveInvalidChars(ref strPic); strSQL = String.Format("select * from tblPicture where strFile like '{0}'", strPic); using (SqlCommand cmd = _connection.CreateCommand()) { cmd.CommandType = CommandType.Text; cmd.CommandText = strSQL; using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader.Read()) { DateTime dtDateTime = (DateTime)reader["strDateTaken"]; reader.Close(); return(dtDateTime); } reader.Close(); } } AddPicture(strPicture, -1); string strDateTime; using (ExifMetadata extractor = new ExifMetadata()) { ExifMetadata.Metadata metaData = extractor.GetExifMetadata(strPic); strDateTime = DateTime.Parse(metaData.DatePictureTaken.DisplayValue).ToString("yyyy-MM-dd HH:mm:ss"); } if (strDateTime != string.Empty && strDateTime != "") { DateTime dtDateTime = DateTime.ParseExact(strDateTime, "yyyy-MM-dd HH:mm:ss", new CultureInfo("")); return(dtDateTime); } else { return(DateTime.MinValue); } } catch (Exception ex) { Log.Error("MediaPortal.Picture.Database exception err:{0} stack:{1}", ex.Message, ex.StackTrace); } return(DateTime.MinValue); }
public int GetRotation(string strPicture) { // Continue only if it's a picture files if (!Util.Utils.IsPicture(strPicture)) { return(-1); } string strSQL = ""; try { string strPic = strPicture; int iRotation; DatabaseUtility.RemoveInvalidChars(ref strPic); strSQL = String.Format("select * from tblPicture where strFile like '{0}'", strPic); using (SqlCommand cmd = _connection.CreateCommand()) { cmd.CommandType = CommandType.Text; cmd.CommandText = strSQL; using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader.Read()) { iRotation = (int)reader["iRotation"]; reader.Close(); return(iRotation); } reader.Close(); } } ExifMetadata extractor = new ExifMetadata(); ExifMetadata.Metadata metaData = extractor.GetExifMetadata(strPicture); iRotation = EXIFOrientationToRotation(Convert.ToInt32(metaData.Orientation.Hex)); AddPicture(strPicture, iRotation); return(0); } catch (Exception ex) { Log.Error("MediaPortal.Picture.Database exception err:{0} stack:{1}", ex.Message, ex.StackTrace); } return(0); }
public static List <GUIOverlayImage> GetExifInfoOverlayImage(this ExifMetadata.Metadata metadata, ref int width, ref int height) { List <GUIOverlayImage> iconList = new List <GUIOverlayImage>(); List <string> infoList = metadata.GetExifInfoList(); bool vertical = height == 0; int i = 0; int step = 50; foreach (string info in infoList) { string image = GUIGraphicsContext.GetThemedSkinFile(@"\media\logos\exif\" + info); if (!File.Exists(image)) { image = Thumbs.Pictures + @"\exif\" + info; if (!File.Exists(image)) { continue; } } if (vertical) { if (height > 0) { height += step; } iconList.Add(new GUIOverlayImage(0, (width + step) * i, width, width, image)); height += width; } else { if (width > 0) { width += step; } iconList.Add(new GUIOverlayImage((height + step) * i, 0, height, height, image)); width += height; } i++; } return(iconList); }
public int AddPicture(string strPicture, int iRotation) { // Continue only if it's a picture files if (!Util.Utils.IsPicture(strPicture)) { return(-1); } if (strPicture == null) { return(-1); } if (strPicture.Length == 0) { return(-1); } lock (typeof(PictureDatabase)) { string strSQL = ""; try { string strPic = strPicture; DatabaseUtility.RemoveInvalidChars(ref strPic); strSQL = String.Format("select * from tblPicture where strFile like '{0}'", strPic); using (SqlCommand cmd = _connection.CreateCommand()) { cmd.CommandType = CommandType.Text; cmd.CommandText = strSQL; using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader.Read()) { int id = (int)reader["idPicture"]; reader.Close(); return(id); } reader.Close(); } } //Changed mbuzina DateTime dateTaken = DateTime.Now; using (ExifMetadata extractor = new ExifMetadata()) { ExifMetadata.Metadata metaData = extractor.GetExifMetadata(strPic); try { DateTimeFormatInfo dateTimeFormat = new DateTimeFormatInfo(); dateTimeFormat.ShortDatePattern = "yyyy:MM:dd HH:mm:ss"; dateTaken = DateTime.ParseExact(metaData.DatePictureTaken.DisplayValue, "d", dateTimeFormat); } catch (Exception) {} // Smirnoff: Query the orientation information // if(iRotation == -1) iRotation = EXIFOrientationToRotation(Convert.ToInt32(metaData.Orientation.Hex)); } strSQL = String.Format("insert into tblPicture (strFile, iRotation, strDateTaken) values('{0}',{1},'{2}')", strPic, iRotation, dateTaken); return(SqlServerUtility.InsertRecord(_connection, strSQL)); } catch (Exception ex) { Log.Error("MediaPortal.Picture.Database exception err:{0} stack:{1}", ex.Message, ex.StackTrace); } return(-1); } }
public static List <string> GetExifInfoList(this ExifMetadata.Metadata metadata) { List <string> infoList = new List <string>(); if (!metadata.EquipmentMake.IsEmpty()) { infoList.Add(@"maker\" + metadata.EquipmentMake.DisplayValue + ".png"); } if (!metadata.CameraModel.IsEmpty()) { infoList.Add(@"camera\" + metadata.CameraModel.DisplayValue + ".png"); } if (!metadata.ISO.IsEmpty()) { infoList.Add(@"iso\" + metadata.ISO.DisplayValue + ".png"); } if (!metadata.Fstop.IsEmpty()) { string fstop = Regex.Replace(metadata.Fstop.DisplayValue, @"f\/(\d+?)[\.,](\d+?)", "$1.$2"); if (!string.IsNullOrEmpty(fstop)) { infoList.Add(@"fstop\" + fstop + ".png"); } } string focal = (!metadata.FocalLength35MM.IsEmpty() ? metadata.FocalLength35MM.DisplayValue : metadata.FocalLength.DisplayValue); if (!string.IsNullOrEmpty(focal)) { int intValue; if (int.TryParse(Regex.Replace(focal, @"(\d+?)(\s.*)?", "$1"), out intValue)) { string lensType = string.Empty; if (intValue > 0 && intValue < 14) { lensType = "fisheye"; } else if (intValue >= 14 && intValue < 40) { lensType = "wide"; } else if (intValue >= 40 && intValue < 85) { lensType = "normal"; } else if (intValue >= 86 && intValue < 400) { lensType = "telephoto"; } else if (intValue >= 400) { lensType = "supertelephoto"; } if (!string.IsNullOrEmpty(lensType)) { infoList.Add(@"lens\" + lensType + ".png"); } } } if (!metadata.ImageDimensions.IsEmpty) { if (metadata.ImageDimensions.Width > 0 && metadata.ImageDimensions.Height > 0) { double dRatio = (double)Math.Max(metadata.ImageDimensions.Width, metadata.ImageDimensions.Height) / (double)Math.Min(metadata.ImageDimensions.Width, metadata.ImageDimensions.Height); string aspect = string.Empty; if (dRatio >= 1.00 && dRatio < 3.00) // 1:1 { // 1:1 - 1, 5:4 - 1.25, 4:3 - 1.33, 3:2 - 1.5, 5:3 - 1.67, 16:9 - 1.78 aspect = Math.Round(dRatio, 2).ToString().Replace(",", "."); } else if (dRatio >= 3) // 3:1 ... Panorama { aspect = @"panorama"; } if (!string.IsNullOrEmpty(aspect)) { infoList.Add(@"aspect\" + aspect + ".png"); } } } if (!metadata.Flash.IsEmpty()) { string flash = string.Empty; if (metadata.Flash.DisplayValue.Contains("red-eye") && metadata.Flash.DisplayValue.Contains("auto")) { flash = "autoredeye"; } else if (metadata.Flash.DisplayValue.Contains("red-eye")) { flash = "redeye"; } else if (metadata.Flash.DisplayValue.Contains("auto")) { flash = "auto"; } else if (metadata.Flash.DisplayValue.Contains("fired")) { flash = "flash"; } else if (metadata.Flash.DisplayValue.ToLowerInvariant().Contains("strobe")) { flash = "strobe"; } else if (metadata.Flash.DisplayValue.Contains("not fire")) { flash = "noflash"; } if (!string.IsNullOrEmpty(flash)) { infoList.Add(@"flash\" + flash + ".png"); } } if (metadata.Location != null) { string latitude = string.Empty; string longitude = string.Empty; if (metadata.Location.Latitude > 0) { latitude = "N"; } else if (metadata.Location.Latitude < 0) { latitude = "S"; } if (metadata.Location.Longitude > 0) { longitude = "E"; } else if (metadata.Location.Longitude < 0) { longitude = "W"; } if (!string.IsNullOrEmpty(latitude) && !string.IsNullOrEmpty(longitude)) { infoList.Add(@"geo\" + latitude[0] + longitude[0] + ".png"); } else { infoList.Add(@"geo\tagged.png"); } } if (!metadata.CountryCode.IsEmpty()) { infoList.Add(@"country\" + metadata.CountryCode.DisplayValue + ".png"); } return(infoList); }
/// <summary> /// Returns latest added Pictures db. /// </summary> /// <param name="type">Type of data to fetch</param> /// <returns>Resultset of matching data</returns> private LatestsCollection GetLatestPictures() { latestPictures = new LatestsCollection(); latestPicturesFiles = new Hashtable(); if (!InitDB()) { return(latestPictures); } int x = 0; try { CurrentFacade.HasNew = false; string sqlQuery = "SELECT strFile, strDateTaken FROM picture ORDER BY strDateTaken DESC LIMIT " + Utils.FacadeMaxNum + ";"; SQLiteResultSet resultSet = PicturesDB.Execute(sqlQuery); CloseDB(); if (resultSet != null) { if (resultSet.Rows.Count > 0) { int i0 = 1; for (int i = 0; i < resultSet.Rows.Count; i++) { string filename = resultSet.GetField(i, 0); if (string.IsNullOrEmpty(filename)) { continue; } // string thumb = String.Format(@"{0}\{1}L.jpg", Thumbs.Pictures, MediaPortal.Util.Utils.EncryptLine(filename)); string thumb = MediaPortal.Util.Utils.GetPicturesLargeThumbPathname(filename); if (!File.Exists(thumb)) { // thumb = String.Format(@"{0}\{1}.jpg", Thumbs.Pictures, MediaPortal.Util.Utils.EncryptLine(filename)); thumb = MediaPortal.Util.Utils.GetPicturesThumbPathname(filename); if (!File.Exists(thumb)) { // thumb = "DefaultPictureBig.png"; thumb = filename; } } if (!File.Exists(thumb)) { continue; } string dateAdded = resultSet.GetField(i, 1); bool isnew = false; try { DateTime dTmp = DateTime.Parse(dateAdded); dateAdded = String.Format("{0:" + Utils.DateFormat + "}", dTmp); isnew = (dTmp > Utils.NewDateTime); if (isnew) { CurrentFacade.HasNew = true; } } catch { } string title = Path.GetFileNameWithoutExtension(Utils.GetFilenameNoPath(filename)).ToUpperInvariant(); string exif = string.Empty; string exifoutline = string.Empty; if (File.Exists(filename)) { using (ExifMetadata extractor = new ExifMetadata()) { ExifMetadata.Metadata metaData = extractor.GetExifMetadata(filename); exif = exif + (!string.IsNullOrEmpty(metaData.CameraModel.DisplayValue) ? metaData.CameraModel.DisplayValue + System.Environment.NewLine : string.Empty); exif = exif + (!string.IsNullOrEmpty(metaData.DatePictureTaken.DisplayValue) ? metaData.DatePictureTaken.DisplayValue + System.Environment.NewLine : string.Empty); exif = exif + (!string.IsNullOrEmpty(metaData.EquipmentMake.DisplayValue) ? metaData.EquipmentMake.DisplayValue + System.Environment.NewLine : string.Empty); exif = exif + (!string.IsNullOrEmpty(metaData.ExposureCompensation.DisplayValue) ? metaData.ExposureCompensation.DisplayValue + System.Environment.NewLine : string.Empty); exif = exif + (!string.IsNullOrEmpty(metaData.ExposureTime.DisplayValue) ?metaData.ExposureTime.DisplayValue + System.Environment.NewLine : string.Empty); exif = exif + (!string.IsNullOrEmpty(metaData.Flash.DisplayValue) ? metaData.Flash.DisplayValue + System.Environment.NewLine : string.Empty); exif = exif + (!string.IsNullOrEmpty(metaData.Fstop.DisplayValue) ? metaData.Fstop.DisplayValue + System.Environment.NewLine : string.Empty); exif = exif + (!string.IsNullOrEmpty(metaData.ImageDimensions.DisplayValue) ? metaData.ImageDimensions.DisplayValue + System.Environment.NewLine : string.Empty); exif = exif + (!string.IsNullOrEmpty(metaData.MeteringMode.DisplayValue) ? metaData.MeteringMode.DisplayValue + System.Environment.NewLine : string.Empty); exif = exif + (!string.IsNullOrEmpty(metaData.Resolution.DisplayValue) ? metaData.Resolution.DisplayValue + System.Environment.NewLine : string.Empty); exif = exif + (!string.IsNullOrEmpty(metaData.ShutterSpeed.DisplayValue) ? metaData.ShutterSpeed.DisplayValue + System.Environment.NewLine : string.Empty); exif = exif + (!string.IsNullOrEmpty(metaData.ViewerComments.DisplayValue) ? metaData.ViewerComments.DisplayValue + System.Environment.NewLine : string.Empty); exifoutline = exifoutline + (!string.IsNullOrEmpty(metaData.EquipmentMake.DisplayValue) ? metaData.EquipmentMake.DisplayValue + " " : string.Empty); exifoutline = exifoutline + (!string.IsNullOrEmpty(metaData.CameraModel.DisplayValue) ? metaData.CameraModel.DisplayValue + " " : string.Empty); exifoutline = exifoutline + (!string.IsNullOrEmpty(metaData.ViewerComments.DisplayValue) ? metaData.ViewerComments.DisplayValue + " " : string.Empty); } } latestPictures.Add(new Latest(dateAdded, thumb, filename, title, exifoutline, null, null, null, null, null, null, null, null, null, null, null, null, null, exif, null, isnew)); latestPicturesFiles.Add(i0, filename); Utils.ThreadToSleep(); x++; i0++; if (x == Utils.FacadeMaxNum) { break; } } } } resultSet = null; } catch (Exception ex) { logger.Error("GetLatestPictures: " + ex.ToString()); } return(latestPictures); }
/// <summary> /// Returns latest added Pictures db. /// </summary> /// <param name="type">Type of data to fetch</param> /// <returns>Resultset of matching data</returns> private LatestsCollection GetLatestPictures() { latestPictures = new LatestsCollection(); latestPicturesFiles = new Hashtable(); if (!PictureDatabase.DbHealth) { return(latestPictures); } int x = 0; try { CurrentFacade.HasNew = false; string sqlQuery = "SELECT strFile, strDateTaken FROM picture" + (PictureDatabase.FilterPrivate ? " WHERE idPicture NOT IN (SELECT DISTINCT idPicture FROM picturekeywords WHERE strKeyword = 'Private')" : string.Empty) + " ORDER BY strDateTaken DESC LIMIT " + Utils.FacadeMaxNum + ";"; List <PictureData> pictures = PictureDatabase.GetPicturesByFilter(sqlQuery, "pictures"); if (pictures != null) { if (pictures.Count > 0) { int i0 = 1; for (int i = 0; i < pictures.Count; i++) { string filename = pictures[i].FileName; if (string.IsNullOrEmpty(filename)) { continue; } // string thumb = String.Format(@"{0}\{1}L.jpg", Thumbs.Pictures, MediaPortal.Util.Utils.EncryptLine(filename)); string thumb = MediaPortal.Util.Utils.GetPicturesLargeThumbPathname(filename); if (!File.Exists(thumb)) { // thumb = String.Format(@"{0}\{1}.jpg", Thumbs.Pictures, MediaPortal.Util.Utils.EncryptLine(filename)); thumb = MediaPortal.Util.Utils.GetPicturesThumbPathname(filename); if (!File.Exists(thumb)) { // thumb = "DefaultPictureBig.png"; thumb = filename; } } if (!File.Exists(thumb)) { continue; } bool isnew = false; isnew = (pictures[i].DateTaken > Utils.NewDateTime); if (isnew) { CurrentFacade.HasNew = true; } string title = Path.GetFileNameWithoutExtension(Utils.GetFilenameNoPath(filename)).ToUpperInvariant(); string exif = string.Empty; string exifoutline = string.Empty; if (File.Exists(filename)) { using (ExifMetadata extractor = new ExifMetadata()) { ExifMetadata.Metadata metaData = extractor.GetExifMetadata(filename); if (!metaData.IsEmpty()) { exif = metaData.ToString(); exifoutline = metaData.ToShortString(); } } } latestPictures.Add(new Latest() { DateTimeAdded = pictures[i].DateTaken, Title = title, Subtitle = exifoutline, Thumb = thumb, Fanart = filename, Classification = exif, IsNew = isnew }); latestPicturesFiles.Add(i0, filename); Utils.ThreadToSleep(); x++; i0++; if (x == Utils.FacadeMaxNum) { break; } } } } } catch (Exception ex) { logger.Error("GetLatestPictures: " + ex.ToString()); } return(latestPictures); }