public static ImageSource GetThumbnailFromImage(string filename, int height)
{
BitmapImage bi = new BitmapImage();
try
{
// create the thumbnail
bi.BeginInit();
bi.DecodePixelHeight = height;
//bi.DecodePixelWidth = width;
bi.CacheOption = BitmapCacheOption.OnLoad;
bi.UriSource = new Uri(configurations.GetAbsoluteContributionPath() + filename);
bi.EndInit();
bi.Freeze();
}
catch (Exception)
{
// could not create thumbnail -- reason: filenotfound or currupt download or ...
// write log
return null;
}
return bi;
}