EvotecIT / ImagePlayground

ImagePlayground is a PowerShell module that provides a set of functions for image processing. Among other things it can create QRCodes, BarCodes, Charts, and do image processing that can help with daily tasks.
MIT License
66 stars 4 forks source link

Get-ImageExif does not support relative paths #7

Closed MrFly72 closed 1 year ago

MrFly72 commented 1 year ago

It seems that Get-ImageExif does not support relative paths and defaults then to the home directory of the user?

PS 15:44h 37.78 ms | C:\Users\thorsten\Pictures\2019> Get-ImageExif -FilePath .\IMG_2014.HEIC
Ausnahme beim Aufrufen von "Load" mit 1 Argument(en):  "Die Datei "C:\Users\thorsten\IMG_2014.HEIC" konnte nicht
gefunden werden."
In C:\Program Files\WindowsPowerShell\Modules\ImagePlayground\0.0.4\ImagePlayground.psm1:94 Zeichen:5
+     $Image = [ImagePlayground.Image]::Load($FilePath)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : FileNotFoundException

Translated: The File ..... cannot be found

PrzemyslawKlys commented 1 year ago

Yes, I typically don't use relative paths so you're always gonna hit this problem in my modules. Probably all commands that take file path don't support it at the moment so that requires fixing. Care to PR?

MrFly72 commented 1 year ago

PR? Pull request ? I am not a C# programmer at all at the moment I am more a powershell-scripter ;-) I was just curious as this is a non standard PS behaviour, as usually any tool taking a filepath can:

MrFly72 commented 1 year ago

Current Workaround can be: eg: Get-ImageExif -file (Resolve-Path .\IMG_2179.jpg).Path Maybe there is a .net c# equivalent to that, which does the magic "by itself"?

PrzemyslawKlys commented 1 year ago

It doesnt have to be added on c# level. Most of the commanda such as get-imagexif are standard powershell functions that just call c#. I guess one could fix it on c#. Its probably an easy fix.

PrzemyslawKlys commented 1 year ago

Ye in c#

var currentDir = @"D:\toto\titi\tata\";
var case1 = Path.GetFullPath(Path.Combine(currentDir, @"test.txt"));
var case2 = Path.GetFullPath(Path.Combine(currentDir, @".\..\..\test\test.txt"));
var case3 = Path.GetFullPath(Path.Combine(currentDir, @".\..\test\test.txt"));
var case4 = Path.GetFullPath(Path.Combine(currentDir, @".\..\..\..\test\test.txt"));
var case5 = Path.GetFullPath(Path.Combine(currentDir, @".\..\..\..\..\test\test.txt"));
var case6 = Path.GetFullPath(Path.Combine(currentDir, @"\\server\share\folder\test".TrimStart('\\')));

So not hard, i'll fix it if there will be no takers. One can even use it in PowerShell [io.path]::GetFullPath(".\Test.ps1")