익명 02:21

Print supported display resolutions with aspect ratios

Print supported display resolutions with aspect ratios

Is there a simple way to list all of supported resolutions and their aspect ratios? I go to Settings > System > Display and get a list of resolutions:

list of resolutions

But I want to test something in 16:10 or other aspect ratios and don't want to do the math each time I look at this menu. Seems like something that's easily automated.

If there's nothing built-in, is there a simple PowerShell or python script that could display the aspect ratios?

I'd like a solution that works on Windows 11, but this problem doesn't seem specific to that version.



Top Answer/Comment:

There are Powershell scripts that can immediately find out your resolutions and aspect ratio. I tried to include refresh rates as well, but the code kept crashing out, so that is left out.

The code as below:

function gcd($a, $b)
{
    $a = [int]$a
    $b = [int]$b

    while ($b -ne 0)
    {
        $t = $b
        $b = $a % $b
        $a = $t
    }

    return $a
}

# Pull supported display modes from WMI
$monitors = Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorListedSupportedSourceModes |
Where-Object Active

$results = foreach ($monitor in $monitors)
{
    $name = $monitor.InstanceName

    foreach ($mode in $monitor.MonitorSourceModes)
    {
        $width  = [int]$mode.HorizontalActivePixels
        $height = [int]$mode.VerticalActivePixels

        if ($width -le 0 -or $height -le 0)
        {
            continue
        }

        $gcdValue = gcd $width $height
        $ratio = "{0}:{1}" -f ($width / $gcdValue), ($height / $gcdValue)

        # Fix known EDID odd ratios
        if ($ratio -eq "683:384")
        {
            $ratio = "~16:9"
        }

        [pscustomobject]@{
            Monitor     = $name
            Resolution  = "$width x $height"
            AspectRatio = $ratio
        }
    }
}

# Clean up output
$results |
Sort-Object Monitor, Resolution -Unique |
Format-Table -AutoSize

It should display your monitor supported resolutions in a chart.

    Monitor                                  Resolution  AspectRatio
    -------                                  ----------  -----------
    DISPLAY\LEN61A6\4&37b31332&0&UID198195_0 1024 x 768  4:3
    DISPLAY\LEN61A6\4&37b31332&0&UID198195_0 1152 x 864  4:3
    ......
상단 광고의 [X] 버튼을 누르면 내용이 보입니다