I have this small utility, called PureRef, it lets me import multiple images and view them as if they were one large image.
In File Explorer, I can right a click a selection consisting of multiple images, copy it and then in PureRef Right Click > Paste. This will paste all of the images found in the Clipboard.
Here is recording showing what I mean
I essentially want to write a function that will let me do Step 1 in PowerShell:
- Copy the image items with something like
$MyPaths | Set-Clipboard
- Switch to the PureRef window
- Paste
Step 2 and 3 are not meant to be done in PowerShell.
I am stuck on implementing Step 1 in PowerShell though, if I have a variable like so:
$MyPaths
Directory: C:\Temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 24/03/2021 19:39 146775 pinterest_490822059382335736.jpg
-a--- 24/03/2021 19:39 114598 pinterest_490822059380529968.jpg
-a--- 24/03/2021 19:39 102667 pinterest_490822059380520311.jpg
Then execute $MyPaths | Set-Clipboard
before switching to the PureRef window and invoking paste (Ctrl
+ V
or Right click
> Paste
) will not work.
Oddly enough the following works:
$MyPaths[0] | Set-Clipboard
I can paste that single image into PureRef, I don't know if this is PowerShell's doing or not. As soon as I attempt to paste more than one image I am back to square one.
In the example of Explorer that I shared. I think Explorer is copying the actual image pixel data.
Is it possible to also do this in PowerShell? Instead of placing paths in the clipboard, place the pixel data there. Or maybe simulate what explorer is doing via a Shell object?
I tried searching and experimenting, the closest I came to a solution is by THIS answer by Ansgar Wiechers, which partly works after I modify it:
Add-Type -Assembly System.Windows.Forms
Add-Type -Assembly System.Drawing
$img = [Drawing.Image]::FromFile($path[1])
[Windows.Forms.Clipboard]::SetImage($img)
But notice the ...FromFile($path[1])
, This solution also only works with a single file.
I really need to pass multiple files from various directories, as I want to take advantage of the complex searching/Selection operations I can perform in PowerShell.