This repository has been archived by the owner on Aug 1, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 2018.1c This doesn't work. I have made a few changes. I'm going to do kind of like an MVC style thing.(I know it has to have it's own name I just don't care.) Added some settings just not all. Added the ability to remove files from list. I belive I fixed all the issues from codacy, but I might have missed a few and created a few more. Fixed: #18 #8 On the way to fixing: #2 # 3 Aw, you guys made me ink. * I don't know what I'm doing Weddings are basically funerals with cake. * 1.0rc1 We are pretty much feature set. There are a few thigns that need to be kinked out, but image conversion is complete and I'm starting on video conversion next.
- Loading branch information
1 parent
56dced0
commit 708993f
Showing
22 changed files
with
1,113 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,48 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<configSections> | ||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > | ||
<section name="Mr_Squirrely_Converters.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> | ||
</sectionGroup> | ||
</configSections> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1"/> | ||
</startup> | ||
<userSettings> | ||
<Mr_Squirrely_Converters.Properties.Settings> | ||
<setting name="Create_Temp" serializeAs="String"> | ||
<value>False</value> | ||
</setting> | ||
<setting name="Temp_Location" serializeAs="String"> | ||
<value>.image_temp</value> | ||
</setting> | ||
<setting name="Images_Delete" serializeAs="String"> | ||
<value>True</value> | ||
</setting> | ||
<setting name="WebP_Lossess" serializeAs="String"> | ||
<value>False</value> | ||
</setting> | ||
<setting name="WebP_Emulate_JPEG" serializeAs="String"> | ||
<value>False</value> | ||
</setting> | ||
<setting name="WebP_Quality" serializeAs="String"> | ||
<value>80</value> | ||
</setting> | ||
<setting name="WebP_RemoveAlpha" serializeAs="String"> | ||
<value>False</value> | ||
</setting> | ||
<setting name="JPEG_Quality" serializeAs="String"> | ||
<value>80</value> | ||
</setting> | ||
<setting name="PNG_Lossess" serializeAs="String"> | ||
<value>True</value> | ||
</setting> | ||
<setting name="PNG_Quality" serializeAs="String"> | ||
<value>80</value> | ||
</setting> | ||
<setting name="PNG_RemoveAlpha" serializeAs="String"> | ||
<value>False</value> | ||
</setting> | ||
</Mr_Squirrely_Converters.Properties.Settings> | ||
</userSettings> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,131 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using ImageMagick; | ||
using NReco.VideoConverter; | ||
|
||
namespace Mr_Squirrely_Converters.Class | ||
{ | ||
class Convert | ||
class Converter | ||
{ | ||
|
||
public void ConvertWebP(List<string> files) { | ||
#region Video Converters | ||
internal static void ConvertWebM(List<string> files) { | ||
try { | ||
|
||
// Currently disabled | ||
//FFMpegConverter video = new FFMpegConverter(); | ||
//foreach (string file in files) { | ||
// string fileName = Path.GetFileNameWithoutExtension(file); | ||
// string fileLocation = Path.GetDirectoryName(file); | ||
// string fileType = Path.GetExtension(file); | ||
// video.ConvertMedia(file, $"{fileLocation}\\{fileName}.webm", Format.webm); | ||
//} | ||
|
||
} | ||
catch (Exception) { | ||
|
||
} | ||
} | ||
|
||
internal static void ConvertMP4(List<string> files) { | ||
|
||
} | ||
#endregion | ||
|
||
#region Image Converters | ||
//If alpha true = remove else = set | ||
internal static void ConvertWebP(List<string> files) { | ||
foreach (string file in files) { | ||
string fileName = Path.GetFileNameWithoutExtension(file); | ||
string fullName = Path.GetFileName(file); | ||
string fileLocation = Path.GetDirectoryName(file); | ||
string fullLocation = Path.GetFullPath(file); | ||
MagickImage image = new MagickImage(file); | ||
image.Settings.SetDefine(MagickFormat.WebP, "-lossless", Options.WebPLossless); | ||
image.Settings.SetDefine(MagickFormat.WebP, "-emulate-jpeg-size", Options.WebPEmulateJPEG); | ||
image.Settings.SetDefine(MagickFormat.WebP, "-alpha", Options.GetWebPRemoveAlpha()); | ||
image.Settings.SetDefine(MagickFormat.WebP, "-quality", Options.WebPQuality.ToString()); | ||
image.Format = MagickFormat.WebP; | ||
image.Write($"{fileLocation}\\{fileName}.webp"); | ||
//I need help on this. There has to be a better way to do this?! | ||
foreach (NewFile newFile in Utils._Images) { | ||
int index = Utils._Images.IndexOf(newFile); | ||
if (Utils._Images[index].Location == fullLocation) { | ||
Utils._Images[index].Converted = "Converted"; | ||
} | ||
} | ||
Utils._MainPage.Dispatcher.Invoke(() => { Utils._MainPage.ImageFiles.Items.Refresh(); }, System.Windows.Threading.DispatcherPriority.Background); | ||
if (Options.CreateTemp) { | ||
if (!Directory.Exists($"{Utils._WorkingDir}\\image_temp")) Directory.CreateDirectory($"{Utils._WorkingDir}\\image_temp"); | ||
File.Copy(file, $"{Utils._WorkingDir}\\image_temp\\{fullName}"); | ||
} | ||
DeleteFile(file); | ||
} | ||
} | ||
|
||
internal void ConvertJPEG(List<string> files) { | ||
internal static void ConvertJPEG(List<string> files) { | ||
foreach (string file in files) { | ||
string fileName = Path.GetFileNameWithoutExtension(file); | ||
string fullName = Path.GetFileName(file); | ||
string fileLocation = Path.GetDirectoryName(file); | ||
string fullLocation = Path.GetFullPath(file); | ||
MagickImage image = new MagickImage(file); | ||
image.Settings.SetDefine(MagickFormat.Jpeg, "-quality", Options.WebPQuality.ToString()); | ||
image.Format = MagickFormat.Jpeg; | ||
image.Write($"{fileLocation}\\{fileName}.Jpeg"); | ||
//I need help on this. There has to be a better way to do this?! | ||
foreach (NewFile newFile in Utils._Images) { | ||
int index = Utils._Images.IndexOf(newFile); | ||
if (Utils._Images[index].Location == fullLocation) { | ||
Utils._Images[index].Converted = "Converted"; | ||
} | ||
} | ||
Utils._MainPage.Dispatcher.Invoke(() => { Utils._MainPage.ImageFiles.Items.Refresh(); }, System.Windows.Threading.DispatcherPriority.Background); | ||
if (Options.CreateTemp) { | ||
if (!Directory.Exists($"{Utils._WorkingDir}\\image_temp")) Directory.CreateDirectory($"{Utils._WorkingDir}\\image_temp"); | ||
File.Copy(file, $"{Utils._WorkingDir}\\image_temp\\{fullName}"); | ||
} | ||
DeleteFile(file); | ||
} | ||
} | ||
|
||
internal void ConvertPNG(List<string> files) { | ||
internal static void ConvertPNG(List<string> files) { | ||
foreach (string file in files) { | ||
string fileName = Path.GetFileNameWithoutExtension(file); | ||
string fullName = Path.GetFileName(file); | ||
string fileLocation = Path.GetDirectoryName(file); | ||
string fullLocation = Path.GetFullPath(file); | ||
MagickImage image = new MagickImage(file); | ||
image.Settings.SetDefine(MagickFormat.Png, "-lossless", Options.WebPLossless); | ||
image.Settings.SetDefine(MagickFormat.Png, "-alpha", Options.GetWebPRemoveAlpha()); | ||
image.Settings.SetDefine(MagickFormat.Png, "-quality", Options.WebPQuality.ToString()); | ||
image.Format = MagickFormat.Png; | ||
image.Write($"{fileLocation}\\{fileName}.Png"); | ||
//I need help on this. There has to be a better way to do this?! | ||
foreach (NewFile newFile in Utils._Images) { | ||
int index = Utils._Images.IndexOf(newFile); | ||
if (Utils._Images[index].Location == fullLocation) { | ||
Utils._Images[index].Converted = "Converted"; | ||
} | ||
} | ||
Utils._MainPage.Dispatcher.Invoke(() => { Utils._MainPage.ImageFiles.Items.Refresh(); }, System.Windows.Threading.DispatcherPriority.Background); | ||
if (Options.CreateTemp) { | ||
if (!Directory.Exists($"{Utils._WorkingDir}\\image_temp")) Directory.CreateDirectory($"{Utils._WorkingDir}\\image_temp"); | ||
File.Copy(file, $"{Utils._WorkingDir}\\image_temp\\{fullName}"); | ||
} | ||
DeleteFile(file); | ||
} | ||
} | ||
#endregion | ||
|
||
private static void DeleteFile(string file) { | ||
if (Options.ImagesDelete) File.Delete(file); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Mr_Squirrely_Converters.Class { | ||
class Options { | ||
|
||
internal static bool CreateTemp { get { return Properties.Settings.Default.Create_Temp; } set { Properties.Settings.Default.Create_Temp = value; } } | ||
internal static string TempLocation { get { return Properties.Settings.Default.Temp_Location; } set { Properties.Settings.Default.Temp_Location = value; } } | ||
internal static bool ImagesDelete { get { return Properties.Settings.Default.Images_Delete; } set { Properties.Settings.Default.Images_Delete = value; } } | ||
internal static bool WebPLossless { get { return Properties.Settings.Default.WebP_Lossess; } set { Properties.Settings.Default.WebP_Lossess = value; } } | ||
internal static bool WebPEmulateJPEG { get { return Properties.Settings.Default.WebP_Emulate_JPEG; } set { Properties.Settings.Default.WebP_Emulate_JPEG = value; } } | ||
internal static double WebPQuality { get { return Properties.Settings.Default.WebP_Quality; } set { Properties.Settings.Default.WebP_Quality = value; } } | ||
internal static bool WebPRemoveAlpha { get { return Properties.Settings.Default.WebP_RemoveAlpha; } set { Properties.Settings.Default.WebP_RemoveAlpha = value; } } | ||
internal static double JPEGQuality { get { return Properties.Settings.Default.JPEG_Quality; } set { Properties.Settings.Default.JPEG_Quality = value; } } | ||
internal static bool PNGLossless { get { return Properties.Settings.Default.PNG_Lossess; } set { Properties.Settings.Default.PNG_Lossess = value; } } | ||
internal static double PNGQuality { get { return Properties.Settings.Default.PNG_Quality; } set { Properties.Settings.Default.PNG_Quality = value; } } | ||
internal static bool PNGRemoveAlpha { get { return Properties.Settings.Default.PNG_RemoveAlpha; } set { Properties.Settings.Default.PNG_RemoveAlpha = value; } } | ||
|
||
internal static void Save() => Properties.Settings.Default.Save(); | ||
|
||
internal static string GetWebPRemoveAlpha() { | ||
if (WebPRemoveAlpha) return "remove"; else return "set"; | ||
} | ||
|
||
internal static string GetPNGRemoveAlpha() { | ||
if (PNGRemoveAlpha) return "remove"; else return "set"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.