Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
89bb87bd14 |
10
.vscode/launch.json
vendored
10
.vscode/launch.json
vendored
@ -11,6 +11,16 @@
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Folder-Helper.dll",
|
||||
"args": [
|
||||
"s",
|
||||
"X",
|
||||
"V:/Tmp/Phares/Pictures/2023 TI2023.6 Fall Samsung",
|
||||
"Day-Helper-2025-07-05",
|
||||
"x-653889110721.jpg~401223300869.jpg",
|
||||
"3648,2736,1~3024,4032,6",
|
||||
"0.341694,0.599963,0.1642,0.279605~0.552357,0.65095,0.195175,0.32383~0.31002,0.42328,0.0379464,0.0459656",
|
||||
"0.259594,0.460161,0.1642,0.279605~0.45477,0.489035,0.195175,0.32383~0.328993,0.446263,0.0379464,0.0459656",
|
||||
"9",
|
||||
"x-825511723~x-444522128~831410304",
|
||||
"s",
|
||||
"X",
|
||||
"\\\\mesfs.infineon.com\\EC_APC\\Production\\Traces\\DEP08CEPIEPSILON\\PollPath",
|
||||
|
112
ADO2025/PI6/Helper-2025-07-05.cs
Normal file
112
ADO2025/PI6/Helper-2025-07-05.cs
Normal file
@ -0,0 +1,112 @@
|
||||
|
||||
using System.Drawing;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace File_Folder_Helper.ADO2025.PI6;
|
||||
|
||||
internal static partial class Helper20250705 {
|
||||
|
||||
internal static void ExportFaces(ILogger<Worker> logger, List<string> args) {
|
||||
string checkFile;
|
||||
logger.LogInformation(args[0]);
|
||||
logger.LogInformation(args[1]);
|
||||
logger.LogInformation(args[2]);
|
||||
logger.LogInformation(args[3]);
|
||||
logger.LogInformation(args[4]);
|
||||
logger.LogInformation(args[5]);
|
||||
logger.LogInformation(args[6]);
|
||||
logger.LogInformation(args[7]);
|
||||
string locationDigits = args[6];
|
||||
string[] mp = args[4].Split('~');
|
||||
string[] mwg = args[5].Split('~');
|
||||
string[] xyz = args[3].Split(',');
|
||||
string[] fileNames = args[2].Split('~');
|
||||
string[] wholePercentages = args[7].Split('~');
|
||||
string sourceDirectory = Path.GetFullPath(args[0].Split('~')[0]);
|
||||
if (mp.Length != mwg.Length || mp.Length != wholePercentages.Length) {
|
||||
logger.LogWarning("Lengths don't match!");
|
||||
} else {
|
||||
foreach (string fileName in fileNames) {
|
||||
checkFile = Path.Combine(sourceDirectory, fileName);
|
||||
if (!File.Exists(checkFile)) {
|
||||
logger.LogWarning("<{file}> doesn't exist!", args[2]);
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < mp.Length; i++) {
|
||||
if (wholePercentages[i].StartsWith("x-")) {
|
||||
logger.LogWarning("Skipping {wholePercentages}", wholePercentages[i]);
|
||||
continue;
|
||||
}
|
||||
Ext(checkFile, xyz, i, mp[i], mwg[i], locationDigits, wholePercentages[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void Ext(string checkFile, string[] xyz, int i, string mp, string mwg, string locationDigits, string wholePercentages) {
|
||||
int width = int.Parse(xyz[0]);
|
||||
int height = int.Parse(xyz[1]);
|
||||
string[] mpValues = mp.Split(',');
|
||||
string[] mwgValues = mwg.Split(',');
|
||||
float mpWidth = float.Parse(mpValues[2]) * width;
|
||||
float mpHeight = float.Parse(mpValues[3]) * height;
|
||||
double mpLeft = (float.Parse(mpValues[0]) * width) - (mpWidth * .5);
|
||||
double mpTop = (float.Parse(mpValues[1]) * height) - (mpHeight * .5);
|
||||
Extract(file: checkFile,
|
||||
width: mpWidth,
|
||||
height: mpHeight,
|
||||
left: mpLeft,
|
||||
top: mpTop,
|
||||
suffix: $"-{i}mp.jpg");
|
||||
float mwgWidth = float.Parse(mwgValues[2]) * width;
|
||||
float mwgHeight = float.Parse(mwgValues[3]) * height;
|
||||
double mwgLeft = double.Parse(mwgValues[0]) * width;
|
||||
double mwgTop = double.Parse(mwgValues[1]) * height;
|
||||
Extract(file: checkFile,
|
||||
width: mwgWidth,
|
||||
height: mwgHeight,
|
||||
left: mwgLeft,
|
||||
top: mwgTop,
|
||||
suffix: $"-{i}mwg.jpg");
|
||||
int length = (int.Parse(locationDigits) - 1) / 4;
|
||||
string[] segments =
|
||||
[
|
||||
wholePercentages[..1],
|
||||
wholePercentages.Substring(1, length),
|
||||
wholePercentages.Substring(3, length),
|
||||
wholePercentages.Substring(5, length),
|
||||
wholePercentages.Substring(7, length)
|
||||
];
|
||||
if (string.Join(string.Empty, segments) == wholePercentages) {
|
||||
if (int.TryParse(segments[1], out int xWholePercent)
|
||||
&& int.TryParse(segments[2], out int yWholePercent)
|
||||
&& int.TryParse(segments[3], out int wWholePercent)
|
||||
&& int.TryParse(segments[4], out int hWholePercent)) {
|
||||
float factor = 100;
|
||||
RectangleF rectangleF = new(xWholePercent / factor, yWholePercent / factor, wWholePercent / factor, hWholePercent / factor);
|
||||
float rectangleFWidth = rectangleF.Width * width;
|
||||
float rectangleFHeight = rectangleF.Height * height;
|
||||
double rectangleFLeft = rectangleF.Left * width;
|
||||
double rectangleFTop = rectangleF.Top * height;
|
||||
Extract(file: checkFile,
|
||||
width: rectangleFWidth,
|
||||
height: rectangleFHeight,
|
||||
left: rectangleFLeft,
|
||||
top: rectangleFTop,
|
||||
suffix: $"-{i}whole-percentages.jpg");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void Extract(string file, float width, float height, double left, double top, string suffix) {
|
||||
RectangleF rectangle = new((float)left, (float)top, width, height);
|
||||
using (Bitmap source = new(file)) {
|
||||
using (Bitmap bitmap = new((int)width, (int)height)) {
|
||||
using (Graphics graphics = Graphics.FromImage(bitmap))
|
||||
graphics.DrawImage(source, new RectangleF(0, 0, width, height), rectangle, GraphicsUnit.Pixel);
|
||||
bitmap.Save($"{file}{suffix}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -175,6 +175,8 @@ internal static class HelperDay
|
||||
ADO2025.PI6.Helper20250628.LogIsoInformation(logger, args);
|
||||
else if (args[1] == "Day-Helper-2025-07-01")
|
||||
ADO2025.PI6.Helper20250701.ProcessDataStandardFormatTo(logger, args);
|
||||
else if (args[1] == "Day-Helper-2025-07-05")
|
||||
ADO2025.PI6.Helper20250705.ExportFaces(logger, args);
|
||||
else
|
||||
throw new Exception(appSettings.Company);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
|
||||
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="8.0.17" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.10" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.5" />
|
||||
<PackageReference Include="TextCopy" Version="6.2.1" />
|
||||
<PackageReference Include="WindowsShortcutFactory" Version="1.2.0" />
|
||||
|
Reference in New Issue
Block a user