Closed dest1n1s closed 1 year ago
What is the minimal windows version that has PowerShell 5.1? Will this PR break support on older version of windows?
It was released along with the Windows 10 Anniversary Update[88] on August 2, 2016, and in Windows Server 2016.[89] PackageManagement now supports proxies, PSReadLine now has ViMode support, and two new cmdlets were added: Get-TimeZone and Set-TimeZone. The LocalAccounts module allows for adding/removing local user accounts.[90] A preview for PowerShell 5.1 was released for Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, and Windows Server 2012 R2 on July 16, 2016,[91] and was released on January 19, 2017.[92]
It seems at least Windows 7 is supported.
Ok, it seems fine, I'll check it and merge it ASAP once I got home. Thanks for your work!
What will happen if the file in the clipboard isn't an image? And can you update the script to check the PowerShell version then decide to use which API?
What will happen if the file in the clipboard isn't an image?
I think it will always gives a result of "no image".
According to the .NET document of Bitmap constructor:
The file name and path can be relative to the application or an absolute path. Use this constructor to open images with the following file formats: BMP, GIF, EXIF, JPG, PNG and TIFF. For more information about supported formats, see Types of Bitmaps. The file remains locked until the Bitmap is disposed.
I haven't found an official description of what will happen when instantiate a System.Drawing.Bitmap using a filename to non-image file, and I don't have a C# environment, so I can't really test it in C#. But I've tested saveclipimg-pc.ps1
with different types of files, including .png, .jpg, .gif and some non-image files, and it works fine. (It's capable to identify and convert all the image files to .png, and output "no image" when facing non-image files.)
And can you update the script to check the PowerShell version then decide to use which API?
Now it'll check the version and decide the way to use.
Thanks for your work! I've published a pre-release version as this change may break functionality on older PCs, you may need to join the preview list to use it.
This PR modify the
saveclipimg-pc.ps1
script, using theGet-Clipboard
command introduced in PowerShell 5.1, to auto-detect whether the image in clipboard (if exists) is a file or a bitmap, and save it to specific path. However, MacOS and Linux have not yet been supported.