Bloom.ImageProcessing.RuntimeImageProcessor.GenerateThumbnail C# (CSharp) Méthode

GenerateThumbnail() private static méthode

private static GenerateThumbnail ( string originalPath, string pathToProcessedImage, int newWidth ) : bool
originalPath string
pathToProcessedImage string
newWidth int
Résultat bool
        private static bool GenerateThumbnail(string originalPath, string pathToProcessedImage, int newWidth)
        {
            using (var originalImage = PalasoImage.FromFileRobustly(originalPath))
            {
                // check if it needs resized
                if (originalImage.Image.Width <= newWidth) return false;

                // calculate dimensions
                var newW = (originalImage.Image.Width > newWidth) ? newWidth : originalImage.Image.Width;
                var newH = newW * originalImage.Image.Height / originalImage.Image.Width;

                using (var newImg = originalImage.Image.GetThumbnailImage(newW, newH, () => false, IntPtr.Zero))
                {
                    SIL.IO.RobustIO.SaveImage(newImg, pathToProcessedImage);
                }
            }

            return true;
        }