Closed elbehery95 closed 7 years ago
Hello, I try it in my windows 10, and it's ok
You can do a test. First save this powershell script to a file named "ps.pc1":
param($imagePath)
# Adapted from https://github.com/octan3/img-clipboard-dump/blob/master/dump-clipboard-png.ps1
Add-Type -Assembly PresentationCore
$img = [Windows.Clipboard]::GetImage()
if ($img -eq $null) {
"no image"
Exit 1
}
if (-not $imagePath) {
"no image"
Exit 1
}
$fcb = new-object Windows.Media.Imaging.FormatConvertedBitmap($img, [Windows.Media.PixelFormats]::Rgb24, $null, 0)
$stream = [IO.File]::Open($imagePath, "OpenOrCreate")
$encoder = New-Object Windows.Media.Imaging.PngBitmapEncoder
$encoder.Frames.Add([Windows.Media.Imaging.BitmapFrame]::Create($fcb)) | out-null
$encoder.Save($stream) | out-null
$stream.Dispose() | out-null
$imagePath
And then you copy a image, open a powershell window, run this script: powershell -f ps.pc1 "D:\\test.png"
, observe the output.
It just prints out the argument given. And image is created at the given location
I have found the issue;
It turns out that if powershell
is not added into the system environmental variables the code required for paste will throw an exception since it is not able to launch the powershell script
I am doing a pull request to fix this issue. Adding the full powershell path into the variable powershell should fix this problem in case users dont have powershell.exe added to system env. vars
Very very thank you for you experiment!
I update plugin, fix this bug and enhance the log system. You can try it.
In settings i am setting the path property to
"pasteImage.path": "${currentFileDir}\\assets"
However when i enter the paste command, the "assets" folder is created but the image is not.