diff --git a/.gitignore b/.gitignore index 9dae5ec..09b8d0f 100644 --- a/.gitignore +++ b/.gitignore @@ -331,3 +331,4 @@ ASALocalRun/ # MFractors (Xamarin productivity tool) working folder .mfractor/ Image Converter/Code/Github.cs +Image Converter/gif2webp.exe diff --git a/Image Converter/Code/Converter.cs b/Image Converter/Code/Converter.cs index d53782c..bca6ecc 100644 --- a/Image Converter/Code/Converter.cs +++ b/Image Converter/Code/Converter.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Text; @@ -45,12 +46,27 @@ private static void WebPConvert() { magickImage.Settings.SetDefine(WEBP, "-quality", $"{Properties.Settings.Default.WebP_Quality}"); magickImage.Format = WEBP; magickImage.Write($"{image}.webp"); - - RemoveImage($"{info.FileName}{info.FileType}", info.FileLocation); } else if (info.FileType != ".webp") { - //Todo: add gif conversion + Process gifProcess = new Process() { + StartInfo = { + FileName = "cmd.exe", + RedirectStandardInput = true, + RedirectStandardOutput = true, + CreateNoWindow = true, + UseShellExecute = false + } + }; + + gifProcess.Start(); + gifProcess.StandardInput.WriteLine($"cd {Environment.CurrentDirectory}"); + //process.StandardInput.WriteLine($"gif2webp.exe {Options.GetWebPQuality()} \"{Image}\" -o \"{infos.FileDirectory()}\\{infos.FileNameWithoutExtension()}.webp\""); + gifProcess.StandardInput.WriteLine($"gif2webp.exe {Properties.Settings.Default.WebP_Quality} \"{imageExt}\" -o \"{image}.webp\""); + gifProcess.StandardInput.Flush(); + gifProcess.StandardInput.Close(); + gifProcess.WaitForExit(); } + RemoveImage($"{info.FileName}{info.FileType}", info.FileLocation); } catch (Exception ex) { Logger.Instance.LogError(ex); @@ -63,7 +79,7 @@ private static void JpegConvert() { string imageExt = $"{info.FileLocation}\\{info.FileName}{info.FileType}"; string image = $"{info.FileLocation}\\{info.FileName}"; - try{ + try { if (info.FileType != ".jpg" && info.FileType != ".jpeg" && info.FileType != ".gif") { MagickImage magickImage = new MagickImage(imageExt); magickImage.Settings.SetDefine(JPEG, "-quality", $"{Properties.Settings.Default.Jpeg_Quality}"); diff --git a/Image Converter/Code/Utilities.cs b/Image Converter/Code/Utilities.cs index 75670dd..873845c 100644 --- a/Image Converter/Code/Utilities.cs +++ b/Image Converter/Code/Utilities.cs @@ -1,4 +1,5 @@ -using MaterialDesignThemes.Wpf; +using MahApps.Metro.Controls; +using MaterialDesignThemes.Wpf; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -17,6 +18,7 @@ public class Utilities { static readonly string[] SizeSuffixes = { "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" }; public static SnackbarMessageQueue messageQueue { get; set; } + public static Flyout flyout { get; set; } public static string SizeSuffix(long value, int decimalPlaces = 1) { if (value < 0) { @@ -64,7 +66,7 @@ public static void PopulateList(string[] droppedFiles) { "“Begin with the end in mind.” – Steven Covey", "“Much of the stress that people feel doesn’t come from having too much to do. It comes from not finishing what they started.” – David Allen", "“It’s not enough to be busy, so are the ants. The question is, what are we busy about?” – Henry David Thoreau", - "“You’ve got to think about big things while you’re doing small things, so that all the small things go in the right direction.” – Alvin Toffler" + "“You’ve got to think about big things while you’re doing small things, so that all the small things go in the right direction.” – Alvin Toffler", "“In the long run, we shape our lives, and we shape ourselves. The process never ends until we die. And the choices we make are ultimately our own responsibility.” ― Eleanor Roosevelt" }; diff --git a/Image Converter/Image Converter.csproj b/Image Converter/Image Converter.csproj index 3ed51b0..8d63229 100644 --- a/Image Converter/Image Converter.csproj +++ b/Image Converter/Image Converter.csproj @@ -52,6 +52,9 @@ 4 preview + + icon.ico + ..\packages\ControlzEx.3.0.2.4\lib\net462\ControlzEx.dll @@ -62,9 +65,6 @@ ..\packages\MahApps.Metro.1.6.5\lib\net47\MahApps.Metro.dll - - ..\packages\Markdig.0.16.0\lib\net40\Markdig.dll - ..\packages\MaterialDesignColors.1.1.3\lib\net45\MaterialDesignColors.dll @@ -80,9 +80,6 @@ ..\packages\Microsoft-WindowsAPICodePack-Shell.1.1.3.3\lib\net452\Microsoft.WindowsAPICodePack.Shell.dll - - ..\packages\Neo.Markdig.Xaml.1.0.5\lib\net47\Neo.Markdig.Xaml.dll - ..\packages\NLog.4.6.2\lib\net45\NLog.dll @@ -179,20 +176,15 @@ Settings.settings True - PublicResXFileCodeGenerator Resources.Designer.cs - SettingsSingleFileGenerator Settings.Designer.cs - - PreserveNewest - @@ -208,6 +200,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + \ No newline at end of file diff --git a/Image Converter/MainWindow.xaml b/Image Converter/MainWindow.xaml index 3563709..1e29d01 100644 --- a/Image Converter/MainWindow.xaml +++ b/Image Converter/MainWindow.xaml @@ -25,14 +25,14 @@ - - @@ -79,7 +79,7 @@ - + Click="DialogButton_Click"/> -