1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
Add-Type -AssemblyName System.Drawing Add-Type -AssemblyName Microsoft.VisualBasic $img = [Microsoft.VisualBasic.Devices.Computer]::new().Clipboard.GetImage() $colors = @{} foreach ($y in (0..($img.Height-1))) { foreach ($x in (0..($img.Width-1))) { $Pixel = $img.GetPixel($x, $y) $color = [System.Drawing.Color]::FromArgb($Pixel.R, $Pixel.G, $Pixel.B) $colorName = $color.Name if (!$colors.ContainsKey($colorName)) { $colors.Add($colorName, 1) } else { $colors[$colorName]++ } } } $colors.GetEnumerator() | Sort-Object -Property Value -Descending | ForEach-Object { Write-Host "Color: $($_.Name) - Count: $($_.Value)" } |