예제 #1
0
        /// <summary>
        /// Gets the image size internal.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="allowSlowMethod">if set to <c>true</c> [allow slow method].</param>
        /// <returns>ImageSize.</returns>
        private ImageSize GetImageSizeInternal(string path, bool allowSlowMethod)
        {
            ImageSize size;

            try
            {
                size = ImageHeader.GetDimensions(path, _logger, _fileSystem);
            }
            catch
            {
                if (!allowSlowMethod)
                {
                    throw;
                }
                //_logger.Info("Failed to read image header for {0}. Doing it the slow way.", path);

                CheckDisposed();

                size = _imageEncoder.GetImageSize(path);
            }

            StartSaveImageSizeTimer();

            return(size);
        }
예제 #2
0
        /// <summary>
        /// Gets the image size internal.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="allowSlowMethod">if set to <c>true</c> [allow slow method].</param>
        /// <returns>ImageSize.</returns>
        private ImageSize GetImageSizeInternal(string path, bool allowSlowMethod)
        {
            //try
            //{
            //    using (var fileStream = _fileSystem.OpenRead(path))
            //    {
            //        using (var file = TagLib.File.Create(new StreamFileAbstraction(Path.GetFileName(path), fileStream, null)))
            //        {
            //            var image = file as TagLib.Image.File;

            //            if (image != null)
            //            {
            //                var properties = image.Properties;

            //                return new ImageSize
            //                {
            //                    Height = properties.PhotoHeight,
            //                    Width = properties.PhotoWidth
            //                };
            //            }
            //        }
            //    }
            //}
            //catch
            //{
            //}

            try
            {
                return(ImageHeader.GetDimensions(path, _logger, _fileSystem));
            }
            catch
            {
                if (allowSlowMethod)
                {
                    return(_imageEncoder.GetImageSize(path));
                }

                throw;
            }
        }
예제 #3
0
        /// <summary>
        /// Gets the size of the image.
        /// </summary>
        private ImageSize GetImageSize(string path, bool allowSlowMethod)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }

            try
            {
                return(ImageHeader.GetDimensions(path, _logger, _fileSystem));
            }
            catch
            {
                if (!allowSlowMethod)
                {
                    throw;
                }
            }

            return(_imageEncoder.GetImageSize(path));
        }