参考网址:
https://code.adonline.id.au/change-image-formats-powershell/
代码:
function ConvertImage{
param ([string]$path)
if (Test-Path $path)
{
#Load required assemblies and get object reference
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
foreach($file in (ls "$path\*.jpg")){
$convertfile = new-object System.Drawing.Bitmap($file.Fullname)
$newfilname = "C:\Users\jtang20\Desktop\pdfFolder\a\1" + ".png"
$convertfile.Save($newfilname, "png")
$file.Fullname
}
}
else
{
Write-Host "Path not found."
}
};ConvertImage -path "C:\Users\jtang20\Desktop\pdfFolder\a"