Automating the world one-liner at a time…
I have a problem with [system.drawing.image]::FromFile
I loaded the drawing namespace via [system.reflection.assembly], because it still reported errors otherwise. However when the class Image was finally available, it didn't work.
It works for bitmap images, but not for icons, nor the JPEGs throwing this:
Exception calling "FromFile" with "1" argument(s): "mainicon.ico"
At line:1 char:40
+ $img = [system.drawing.image]::FromFile( <<<< "mainicon.ico")
Exception calling "FromFile" with "1" argument(s): "35-souboj.jpg"
+ $img = [system.drawing.image]::FromFile( <<<< "35-souboj.jpg")
Any idea why? (It's issue only in PowerShell, in C# compiled application it works perfectly.)
Hey, Pepa - I know I'm a little late on this, but this was the only result I found on the Interwebs about this issue.
Turns out that this method required me to use the full path to a file for it to work - I.E.: $file = [System.Drawing.Image]::FromFile( "F:\Media Folder\Main Pictures Folder\1256705287365.jpg")
Made me feel like a moron once I used a full path instead of a relative one. Hope this helps others that may stumble into this.