我尝试制作一个脚本,以减小文件夹中图像的大小。但我总是有一个错误信息。 我必须在同一个文件夹和子文件夹中缩小文件大小PowerShell - 减小图像大小
您能帮我建立我的脚本吗?
预先感谢您。
下面是脚本:
$source = "U:\TEST\Compression\images"
$exclude_list = "(Imprimerie|Photos)"
$source_listephotos = Get-ChildItem $source -Recurse | where {$_.FullName -notmatch $exclude_list}
foreach ($source_photos in $source_listephotos) {
$source_photos
Resize-Image -InputFile $source_photos.FullName -Scale 30 -OutputFile (Join-Path $source $source_photos.Name) -Verbose
}
而且这里的错误消息:
Exception calling "Save" with "1" argument(s): "A generic error occurred in GDI+."
At C:\windows\system32\windowspowershell\v1.0\Modules\Resize-Image\Resize-Image.psm1:70 char:9
+ $img2.Save($OutputFile);
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ExternalException
谢谢您的帮助。 我可以缩小图像的大小吗?修改脚本修改图片扩展名。 – pcarrey
对不起,这是我,我在$ source中犯了一个错误。 – pcarrey
我有其他问题。我必须排除一些带有照片的文件夹,但参数-exclude不起作用。我该怎么办? – pcarrey