Exemplo n.º 1
0
        public Size GetDimensions()
        {
            if (_size == null)
            {
                EnsureFileSupportsResizing();

                var fs         = _fs.OpenFile(Path);
                var image      = Image.FromStream(fs);
                var fileWidth  = image.Width;
                var fileHeight = image.Height;
                fs.Close();
                image.Dispose();

                _size = new Size(fileWidth, fileHeight);
            }
            return(_size.Value);
        }
Exemplo n.º 2
0
        public Size GetDimensions()
        {
            if (_size == null)
            {
                if (_fs.FileExists(Path))
                {
                    EnsureFileSupportsResizing();

                    using (var fs = _fs.OpenFile(Path))
                    {
                        _size = ImageHelper.GetDimensions(fs);
                    }
                }
                else
                {
                    _size = new Size(-1, -1);
                }
            }
            return(_size.Value);
        }
Exemplo n.º 3
0
        private static string DoResize(MediaFileSystem fileSystem, string path, string extension, int width, int height, int maxWidthHeight, string fileNameAddition)
        {
            var fs = fileSystem.OpenFile(path);
            var image = Image.FromStream(fs);
            fs.Close();

            string fileNameThumb = String.IsNullOrEmpty(fileNameAddition) ?
                string.Format("{0}_UMBRACOSYSTHUMBNAIL.jpg", path.Substring(0, path.LastIndexOf("."))) :
                string.Format("{0}_{1}.jpg", path.Substring(0, path.LastIndexOf(".")), fileNameAddition);

            var thumb = GenerateThumbnail(fileSystem,
                image,
                maxWidthHeight,
                width,
                height,
                path,
                extension,
                fileNameThumb,
                maxWidthHeight == 0);

            fileNameThumb = thumb.Item3;

            image.Dispose();

            return fileNameThumb;
        }
Exemplo n.º 4
0
        private static Tuple<int, int> GetDimensions(MediaFileSystem fileSystem, string path)
        {
            var fs = fileSystem.OpenFile(path);
            var image = Image.FromStream(fs);
            var fileWidth = image.Width;
            var fileHeight = image.Height;
            fs.Close();
            image.Dispose();

            return new Tuple<int, int>(fileWidth, fileHeight);
        }