Beispiel #1
0
        public ImageInfo(string relativePath)
        {
            _fs = FileSystemProviderManager.Current.GetFileSystemProvider <MediaFileSystem>();

            try
            {
                RelativePath = relativePath;

                //This get's the IFileSystem's path based on the URL (i.e. /media/blah/blah.jpg )
                Path = _fs.GetRelativePath(relativePath);

                using (var stream = _fs.OpenFile(Path))
                    using (image = Image.FromStream(stream))
                    {
                        var fileName = _fs.GetFileName(Path);
                        Name = fileName.Substring(0, fileName.LastIndexOf('.'));

                        DateStamp = _fs.GetLastModified(Path).Date;
                        Width     = image.Width;
                        Height    = image.Height;
                        Aspect    = (float)Width / Height;
                    }
            }
            catch (Exception)
            {
                Width  = 0;
                Height = 0;
                Aspect = 0;
            }
        }