diff --git a/ImageOptimize.csx b/ImageOptimize.csx new file mode 100644 index 0000000..8e6aca7 --- /dev/null +++ b/ImageOptimize.csx @@ -0,0 +1,45 @@ +/* + for %%i in (*.png) do pngquant %%i --force --output %%i --skip-if-larger + for %%i in (*.jpg) do jpegtran -copy none -optimize -perfect %%i %%i + * + */ + + var files = Directory.EnumerateFiles(".", "*.png" + , new EnumerationOptions { + RecurseSubdirectories = true + , AttributesToSkip = FileAttributes.ReparsePoint + , IgnoreInaccessible = true + }) + .ToArray(); + + + Parallel.ForEach(files, file => { + var startInfo = new ProcessStartInfo { + FileName = "pngquant" + , Arguments + = $"\"{file}\" --force --output \"{file}\" --skip-if-larger" + }; + using var p = Process.Start(startInfo); + p.WaitForExit(); + Console.WriteLine($"{file}: {p.ExitCode}"); + }); + + files = new[] { "*.jpg", "*.jpeg" } + .SelectMany(x => Directory.EnumerateFiles( + ".", x + , new EnumerationOptions { + RecurseSubdirectories = true + , AttributesToSkip = FileAttributes.ReparsePoint + , IgnoreInaccessible = true + })) + .ToArray(); + + Parallel.ForEach(files, file => { + var startInfo = new ProcessStartInfo { + FileName = "jpegtran" + , Arguments = $"-copy none -optimize -perfect \"{file}\" \"{file}\"" + }; + using var p = Process.Start(startInfo); + p.WaitForExit(); + Console.WriteLine($"{file}: {p.ExitCode}"); + }); \ No newline at end of file diff --git a/NSCodeAnalysis.sln.DotSettings b/NSCodeAnalysis.sln.DotSettings index 5f4f66e..6bb3515 100644 --- a/NSCodeAnalysis.sln.DotSettings +++ b/NSCodeAnalysis.sln.DotSettings @@ -2,10 +2,6 @@ DO_NOT_SHOW DO_NOT_SHOW NEVER - True - True - True - True False 1 1 diff --git a/logo.png b/logo.png index d1ca974..35c2fb5 100644 Binary files a/logo.png and b/logo.png differ