using namespace System.Drawing
Add-Type -AssemblyName System.Drawing # Specify System.Drawing.Common on PS Core
$filename = 'DSCI0001.jpg'
$filepath = 'C:\Users\Michael\Pictures\AllPictures\'
$filepathComplete = $filepath + $filename
$copyFilenameComplete = $filepath + 'copy' + $filename
Copy-Item -Path $filepathComplete -Destination $copyFilenameComplete
$BitMap = [Bitmap]::FromFile((Resolve-Path $filepathComplete).ProviderPath)
$rotWerte = 0
$anzahlPixel = 0
foreach($h in 1..$BitMap.Height){
foreach($w in 1..$BitMap.Width) {
$rotWerte = $rotWerte + $BitMap.GetPixel($w - 1,$h - 1).R
$anzahlPixel = $anzahlPixel + 1
}
}
$rotDurchschnittsWert = $rotWerte / $anzahlPixel
$newFileName = 'red' + $rotDurchschnittsWert + "__" + $filename
Rename-Item $copyFilenameComplete $newFileName