<commit_before>﻿using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;

namespace GalleryMVC_With_Auth.Helpers
{
    public static class ThumbnailCreater
    {
        public static void ToTmb(string path, string tmbpath)
        {
            var thumb = Image.FromFile(path).GetThumbnailImage(250, 250, () => false, IntPtr.Zero);
            var myEncoderParameters = new EncoderParameters(1){Param = {[0] = new EncoderParameter(Encoder.Quality, 50L)}};
            thumb.Save(tmbpath, GetEncoder(ImageFormat.Jpeg), myEncoderParameters);
        }

        private static ImageCodecInfo GetEncoder(ImageFormat format)
        {
            return ImageCodecInfo.GetImageDecoders().FirstOrDefault(codec => codec.FormatID == format.Guid);
        }
    }
}<commit_msg>Refactoring: encoding image to progressive jpeg<commit_after>﻿using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;

namespace GalleryMVC_With_Auth.Helpers
{
    public static class ThumbnailCreater
    {
        public static void ToTmb(string path, string tmbpath)
        {
            var thumb = Image.FromFile(path).GetThumbnailImage(250, 250, () => false, IntPtr.Zero);
            var myEncoderParameters = new EncoderParameters(3)
            {
                Param =
                {
                    [0] = new EncoderParameter(Encoder.Quality, 100L),
                    [1] = new EncoderParameter(Encoder.ScanMethod, (int) EncoderValue.ScanMethodInterlaced),
                    [2] = new EncoderParameter(Encoder.RenderMethod, (int) EncoderValue.RenderProgressive)
                }
            };
            thumb.Save(tmbpath, GetEncoder(ImageFormat.Jpeg), myEncoderParameters);
        }

        private static ImageCodecInfo GetEncoder(ImageFormat format)
        {
            return ImageCodecInfo.GetImageDecoders().FirstOrDefault(codec => codec.FormatID == format.Guid);
        }
    }
}
{'fraction_non_alphanumeric': 0.09408740359897172, 'fraction_numerical': 0.011825192802056555, 'mean_word_length': 2.651031894934334, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3947264', 'n_tokens_mistral': 557, 'n_tokens_neox': 534, 'n_words': 110}