<commit_before>﻿using System.Drawing;
using System.IO;
using Microsoft.Extensions.CommandLineUtils;

namespace ImageOverlay
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var app = new CommandLineApplication
            {
                Name = "ImageOverlay",
                Description = "ImageOverlay"
            };
            app.HelpOption("-?|-h|--help");
            app.Arguments.Add(new CommandArgument {Name = "image 1", MultipleValues = true});
            app.Arguments.Add(new CommandArgument {Name = "image 2"});

            int execute = app.Execute(args);

            if (execute != 0 || args.Length <= 1) return;

            args[0] = "C:\\Repos\\bitbucket\\UWP\\AppW8RT\\Assets\\speedy.icon-150-wide.scale-100.png";
            args[1] = "C:\\Repos\\bitbucket\\UWP\\AppW8RT\\Assets\\beta.png";
            if (File.Exists(args[0]) && File.Exists(args[1]))
            {
                Image image1 = Image.FromFile(args[0]);
                Image image2 = Image.FromFile(args[1]);
                using (Graphics g = Graphics.FromImage(image1))
                {
                    int x = image1.Width - image2.Width;
                    int y = image1.Height - image2.Height;
                    g.DrawImage(image2, x, 0);
                }

                image1.Save("C:\\Repos\\bitbucket\\UWP\\AppW8RT\\Assets\\test.png");
            }
            else
            {
                
            }
        }
    }
}<commit_msg>Add add overlay using pattern matching<commit_after>﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;

namespace ImageOverlay
{
    public class Program
    {
        private const string Usage = @"ImageOverlay <source image> <overlay image>";

        public static void Main(string[] args)
        {
            if (args.Length < 2) Console.WriteLine(Usage);

            args[0] = "C:\\Repos\\bitbucket\\UWP\\AppW8RT\\Assets\\VisualAssets\\App.Tile.*";
            args[1] = "C:\\Repos\\bitbucket\\UWP\\AppW8RT\\Assets\\VisualAssets\\beta.png";
            if (File.Exists(args[0]))
            {
                AddOverlay(args[0], args[1]);
            }
            else
            {
                string directoryName = Path.GetDirectoryName(args[0]);
                string fileName = Path.GetFileName(args[0]);
                ProcessDirectory(directoryName, fileName, args[1]);
            }
        }

        private static void ProcessDirectory(string directoryPath, string searchPattern, string overlayPath)
        {
            IEnumerable<string> enumerateFiles = Directory.EnumerateFiles(directoryPath, searchPattern);
            foreach (string filePath in enumerateFiles)
            {
                AddOverlay(filePath, overlayPath);
            }
        }

        private static void AddOverlay(string sourcePath, string overlayPath)
        {
            string tmpSavePath = $"C:\\Repos\\bitbucket\\UWP\\AppW8RT\\Assets\\VisualAssets\\tmp.{Path.GetExtension(sourcePath)}";
            using (Image image1 = Image.FromFile(sourcePath))
            using (Image image2 = Image.FromFile(overlayPath))
            using (Graphics g = Graphics.FromImage(image1))
            {
                float x = (image1.Width / image1.HorizontalResolution - image2.Width / image2.HorizontalResolution) *
                          image1.HorizontalResolution;
                g.DrawImage(image2, x, 0);

                image1.Save(tmpSavePath, GetEncoder(image1.RawFormat), GetEncoderParameters());
            }
            File.Delete(sourcePath);
            File.Move(tmpSavePath, sourcePath);
        }

        private static EncoderParameters GetEncoderParameters()
        {
            return new EncoderParameters(1) {Param = {[0] = new EncoderParameter(Encoder.Quality, 100L)}};
        }

        private static ImageCodecInfo GetEncoder(ImageFormat format)
        {
            ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
            foreach (ImageCodecInfo codec in codecs)
            {
                if (codec.FormatID == format.Guid)
                {
                    return codec;
                }
            }
            return null;
        }
    }
}
{'fraction_non_alphanumeric': 0.11330851558864588, 'fraction_numerical': 0.013494648673801768, 'mean_word_length': 1.7140151515151516, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, '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': '2813509', 'n_tokens_mistral': 1190, 'n_tokens_neox': 1138, 'n_words': 222}