-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added drag-n-drop feature - Just drop files to convert/scale them - Added blur util - Added preview feature for noise and blur - Noise intensity can now be randomized - Added dataset util "Delete Files Not Present In Both Folders" - Added "config" tab with option to include incompatible files for file operations - "Delete Source" gets ignored if input & output are the same files (e.g. when re-encoding images)
- Loading branch information
N00MKRAD
committed
Aug 3, 2020
1 parent
719894e
commit bdfe852
Showing
22 changed files
with
813 additions
and
189 deletions.
There are no files selected for viewing
Binary file not shown.
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,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace MagickUtils | ||
{ | ||
class Config | ||
{ | ||
static string filename = "magickutils.ini"; | ||
public static bool fileOperationsNoExtFilter = true; | ||
|
||
public static void WriteConfig () | ||
{ | ||
string cfgString = ""; | ||
cfgString += "fileOperationsNoExtFilter" + "=" + fileOperationsNoExtFilter.ToString() + "\n"; | ||
File.WriteAllText(Path.Combine(IOUtils.GetAppDataDir(), filename), cfgString); | ||
MessageBox.Show("Config saved.", "Message"); | ||
} | ||
|
||
public static void ReadConfig () | ||
{ | ||
string cfgPath = Path.Combine(IOUtils.GetAppDataDir(), filename); | ||
if(!File.Exists(cfgPath)) | ||
return; | ||
string cfgString = File.ReadAllText(cfgPath); | ||
fileOperationsNoExtFilter = GetBool("fileOperationsNoExtFilter", cfgString); | ||
} | ||
|
||
public static bool GetBool (string boolname, string cfgContent) | ||
{ | ||
string[] lines = cfgContent.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); | ||
foreach(string line in lines) | ||
{ | ||
if (line.Contains(boolname)) | ||
{ | ||
string boolValString = line.Trim().Replace(boolname, "").Replace("=", ""); | ||
return boolValString.ToLower() == "true"; | ||
} | ||
} | ||
return false; | ||
} | ||
} | ||
} |
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,69 @@ | ||
using ImageMagick; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace MagickUtils | ||
{ | ||
class EffectsTabHelper | ||
{ | ||
public static bool useGaussNoise; | ||
public static bool useLapNoise; | ||
public static bool usePoiNoise; | ||
public static bool useUniNoise; | ||
public static int attenMin; | ||
public static int attenMax; | ||
public static bool monochrome; | ||
|
||
public static int blurRadiusMin; | ||
public static int blurRadiusMax; | ||
|
||
public static void NoisePreview () | ||
{ | ||
Program.mainForm.SetNoiseVars(); | ||
FileInfo firstImg = IOUtils.GetFiles()[0]; | ||
string tempImgPath = Path.Combine(IOUtils.GetAppDataDir(), "noisepreview" + firstImg.Extension); | ||
if(File.Exists(tempImgPath)) File.Delete(tempImgPath); | ||
File.Copy(firstImg.FullName, tempImgPath); | ||
Random rand = new Random(); | ||
EffectsUtils.AddNoise(tempImgPath, GetNoiseTypeList(), attenMin, attenMax, monochrome); | ||
Program.mainForm.PreviewImage(tempImgPath); | ||
} | ||
|
||
public static void NoiseApply () | ||
{ | ||
Program.mainForm.SetNoiseVars(); | ||
EffectsUtils.AddNoiseDir(GetNoiseTypeList(), attenMin, attenMax, monochrome); | ||
} | ||
|
||
static List<NoiseType> GetNoiseTypeList () | ||
{ | ||
List<NoiseType> noiseTypes = new List<NoiseType>(); | ||
if(useGaussNoise) noiseTypes.Add(NoiseType.Gaussian); | ||
if(useLapNoise) noiseTypes.Add(NoiseType.Laplacian); | ||
if(usePoiNoise) noiseTypes.Add(NoiseType.Poisson); | ||
if(useUniNoise) noiseTypes.Add(NoiseType.Uniform); | ||
return noiseTypes; | ||
} | ||
|
||
public static void BlurPreview () | ||
{ | ||
Program.mainForm.SetBlurVars(); | ||
FileInfo firstImg = IOUtils.GetFiles()[0]; | ||
string tempImgPath = Path.Combine(IOUtils.GetAppDataDir(), "blurpreview" + firstImg.Extension); | ||
if(File.Exists(tempImgPath)) File.Delete(tempImgPath); | ||
File.Copy(firstImg.FullName, tempImgPath); | ||
EffectsUtils.Blur(tempImgPath, blurRadiusMin, blurRadiusMax); | ||
Program.mainForm.PreviewImage(tempImgPath); | ||
} | ||
|
||
public static void BlurApply () | ||
{ | ||
Program.mainForm.SetBlurVars(); | ||
EffectsUtils.BlurDir(blurRadiusMin, blurRadiusMax); | ||
} | ||
} | ||
} |
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.