Skip to content

Commit

Permalink
Merge pull request #49 from 0x78654C/v1.8.2-exif
Browse files Browse the repository at this point in the history
V1.8.2 exif
  • Loading branch information
0x78654C committed May 9, 2024
2 parents 5de16c3 + 65388c6 commit 82d73b4
Show file tree
Hide file tree
Showing 8 changed files with 408 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Commands/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.7.5.0")]
[assembly: AssemblyFileVersion("1.7.5.0")]
[assembly: AssemblyVersion("1.7.6.0")]
[assembly: AssemblyFileVersion("1.7.6.0")]
61 changes: 61 additions & 0 deletions Commands/TerminalCommands/ConsoleSystem/Exif.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Core;
using Core.SystemTools;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Versioning;

namespace Commands.TerminalCommands.ConsoleSystem
{
[SupportedOSPlatform("windows")]
public class Exif: ITerminalCommand
{
public string Name => "exif";
private static List<string> s_imgExt = new List<string>() {
".jpg",
".jpeg",
".jpe",
".tiff",
".png",
".tff"
};
private static string s_helpMessage = $@"Usage of exif command:
exif <path_to_image_file>.
Can be used with the following parameters:
exif -h : Displays this message.
Attention: Works only with the following extensions: {string.Join(", ",s_imgExt)}.
";
public void Execute(string args)
{
try
{
if (args == $"{Name} -h")
{
Console.WriteLine(s_helpMessage);
return;
}

var pathFile = args.Replace($"{Name}","").Trim();
if (File.Exists(pathFile))
{

var fileInfo = new FileInfo(pathFile);
if (s_imgExt.Contains(fileInfo.Extension.ToLower()))
ExifLib.GetExifInfo(fileInfo.FullName);
else
FileSystem.ErrorWriteLine($"Format '{fileInfo.Extension}' unsupported! Use -h for check avaible formats.");
}
else
{
FileSystem.ErrorWriteLine($"File does not exist: '{pathFile}'");
}
}
catch(Exception e)
{
FileSystem.ErrorWriteLine(e.Message);
}
}
}
}
1 change: 1 addition & 0 deletions Commands/TerminalCommands/ConsoleSystem/Help.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ xTerminal Copyright @ 2020-2023 0x078654c
locate -- Searches for files and directories, in the current directory and subdirectories that contains a specific text. Use -h for additional help.
echo -- Write/append data to a file. Use -h for additional help.
diff -- Outputs the difference between two files. Use -h for additional help.
exif -- Extracts image metadata. Use -h for additional help.
---------------------- Networking ----------------------
ifconfig -- Display onboard Network Interface Cards configuration (Ethernet and Wireless)
Expand Down
20 changes: 20 additions & 0 deletions Core/FileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,5 +362,25 @@ public static void GetMD5File(ref string sourceMD5, ref double sizeSource, ref s
}
}
}

/// <summary>
/// Convert byte[] to uLong.
/// </summary>
/// <param name="bytes"></param>
/// <returns></returns>
public static ulong BytesToUInt64(byte[] bytes)
{
if (bytes == null)
return 0;
if (bytes.Length > 8)
return 0;

ulong result = 0;
for (int i = 0; i < bytes.Length; i++)
{
result |= (ulong)bytes[i] << (i * 8);
}
return result;
}
}
}
4 changes: 2 additions & 2 deletions Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.6.0")]
[assembly: AssemblyFileVersion("1.5.6.0")]
[assembly: AssemblyVersion("1.5.7.0")]
[assembly: AssemblyFileVersion("1.5.7.0")]
Loading

0 comments on commit 82d73b4

Please sign in to comment.