Skip to content

Commit 0401dd7

Browse files
committed
Remove similarity comparison (WIP)
1 parent 3bd6959 commit 0401dd7

File tree

4 files changed

+18
-46
lines changed

4 files changed

+18
-46
lines changed

SmartImage/Engines/Other/ImgOpsEngine.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Novus.Win32;
44
using RestSharp;
55
using SimpleCore.Console.CommandLine;
6+
using SimpleCore.Numeric;
67
using SimpleCore.Utilities;
78

89
#nullable enable

SmartImage/Searching/FullSearchResult.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Novus.Win32;
1212
using SimpleCore.Console.CommandLine;
1313
using SimpleCore.Net;
14+
using SimpleCore.Numeric;
1415
using SimpleCore.Utilities;
1516
using SmartImage.Core;
1617
using SmartImage.Engines;
@@ -36,7 +37,7 @@ public FullSearchResult(SearchEngineOptions src, Color color, string name, strin
3637
Similarity = similarity;
3738
ExtendedInfo = new List<string>();
3839
ExtendedResults = new List<FullSearchResult>();
39-
40+
4041
}
4142

4243
/// <summary>
@@ -45,7 +46,7 @@ public FullSearchResult(SearchEngineOptions src, Color color, string name, strin
4546
public SearchEngineOptions Engine { get; }
4647

4748
/// <summary>
48-
/// Whether this result is a result from a priority engine
49+
/// Whether this result is a result from a priority engine (<see cref="SearchConfig.PriorityEngines"/>)
4950
/// </summary>
5051
public bool IsPriority => SearchConfig.Config.PriorityEngines.HasFlag(Engine);
5152

@@ -87,7 +88,11 @@ public override NConsoleFunction CtrlFunction
8788
Debug.WriteLine("Downloading");
8889

8990
try {
90-
string? path = Network.DownloadUrl(Url);
91+
NConsole.WriteSuccess("Downloading...");
92+
93+
94+
95+
string? path = Network.DownloadUrl(Url);
9196

9297
NConsole.WriteSuccess("Downloaded to {0}", path);
9398

@@ -364,7 +369,10 @@ public static FullSearchResult GetOriginalImageResult(string imageUrl, FileInfo
364369

365370
double mpx = MathHelper.ConvertToUnit(width * height, MetricUnit.Mega);
366371

367-
string infoStr = $"Info: {imageFile.Name} ({fileSizeMegabytes:F} MB) ({mpx:F} MP) ({fileFormat.Name})";
372+
var aspectRatio = new Fraction(width, height).ToString().Replace('/', ':');
373+
374+
string infoStr =
375+
$"Info: {imageFile.Name} ({aspectRatio}) ({mpx:F} MP) ({fileSizeMegabytes:F} MB) ({fileFormat.Name})";
368376

369377
result.ExtendedInfo.Add(infoStr);
370378

SmartImage/Searching/SearchClient.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,12 @@ private static async void RunAnalysis(FullSearchResult best)
123123
var task = Task.Run(() =>
124124
{
125125
if (!best.IsAnalyzed) {
126-
var d = Images.Similarity(best.Url, SearchConfig.Config.Image);
127-
128-
if (d.HasValue)
129-
{
130-
best.Similarity = ((float)d);
131-
}
126+
//todo
132127
}
133128

134129
best.IsAnalyzed = true;
135130

136131

137-
138132
});
139133

140134
await task;
@@ -219,13 +213,11 @@ public async void Start()
219213
/*
220214
*
221215
*/
222-
216+
223217
Debug.WriteLine($"Analyzing");
224218

225219

226-
while (!Results.All(r=>r.IsAnalyzed)) {
227-
228-
}
220+
while (!Results.All(r => r.IsAnalyzed)) { }
229221

230222
Debug.WriteLine($"Analysis complete");
231223

SmartImage/Utilities/Images.cs

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Diagnostics;
44
using System.Drawing;
5+
//using System.Drawing;
56
using System.IO;
67
using System.Linq;
78
using System.Net;
@@ -24,37 +25,7 @@ internal static class Images
2425
* Shipwreck phash - cross correlation
2526
*/
2627

27-
public static double? Similarity(string url, string f)
28-
{
29-
var m = Network.IdentifyType(url);
30-
31-
if (m == null) {
32-
return null;
33-
}
34-
35-
var t = Network.IsImage(m);
36-
37-
Debug.WriteLine($"{url} is image: {t}");
38-
39-
40-
if (t) {
41-
42-
43-
// using var s = Image.FromFile(f);
44-
// using var s2 = Image.FromStream(new WebClient().OpenRead(url));
45-
//
46-
//
47-
//
48-
// return Similarity(s, s2);
49-
}
50-
51-
return null;
52-
}
53-
54-
public static double? Similarity(Image a, Image b)
55-
{
56-
return null;
57-
}
28+
5829

5930
internal static (int Width, int Height) GetDimensions(string img)
6031
{

0 commit comments

Comments
 (0)