Ich habe ein Skript, das Bild reduziert, aber ich habe gerade festgestellt, dass einige Fotos vergrößert sind. Zum Beispiel habe ich ein Foto mit der Größe 808 Ko, nach der Ausführung meines Skripts ist die Größe des Bildes 1520 Ko.Manchmal funktioniert die Bildreduzierung nicht
Warum einige Fotos vergrößert und nicht andere?
Hier mein Skript:
$source = "P:\PAULINE DF informatique\Communication\*.jpg"
$exclude_list = "(LOGOS ET DIVERS SUPPORT|!CARTES DE VOEUX 2017|LOGO)"
$scale = 2.2
$source_listephotos = Get-ChildItem $source -Recurse | where {$_.FullName -notmatch $exclude_list}
$log = "U:\TEST\Photos - test\log_photo_2.txt"
foreach ($source_photos in $source_listephotos) {
$log_image = Get-Content "U:\TEST\Photos - test\log_photo_2.txt"
for ($a = 1; $a -lt 100; $a++) {
Write-Progress -Activity "Working ..." -PercentComplete $a -CurrentOperation "$a% complete" -Status "Please Wait."
}
if ($log_image -eq $source_photos) {Write-Host OK}
else {
$source = [System.Drawing.Image]::FromFile($source_photos.FullName)
$size = "$([int]($source.Width/$scale)), $([int]($source.Height/$scale))"
$dest = New-Object System.Drawing.Bitmap($source, $size)
$source.Dispose()
$dest.Save($source_photos.Fullname)
$dest.Dispose()
}
if($? -eq $false){echo "$source_photos pas compressé" | out-file -append $log}
else
{echo "$source_photos" | out-file -append $log}
}
Vielen Dank für die Erklärung, ich habe verstanden. Ich versuche die Lösung, aber in "c: \ Pfad zu Datei" habe ich "$ source" gesetzt. Danke nochmal – pcarrey