Пример #1
0
        /// <summary>
        /// Optimizes the image based on the settings in the arguments.
        /// </summary>
        public static async Task OptimizeImage(this Blob blob, int maxWidth, int maxHeight, int quality, bool toJpeg = true)
        {
            if (!Blob.HasFileDataInMemory(blob))
            {
                return;
            }
            var data = await blob.GetFileDataAsync();

            if (data.Length < 100)
            {
                return;
            }

            var optimizer = new ImageOptimizer(maxWidth, maxHeight, quality);

            blob.SetData(optimizer.Optimize(data, toJpeg));
        }