Add-Type -AssemblyName System.Drawing $src = [System.Drawing.Image]::FromFile('C:\Users\12914\Desktop\sky\hmr_live.png') $w = $src.Width $h = $src.Height $cropH = [int]($h * 0.18) $bmp = New-Object System.Drawing.Bitmap($w, $cropH) $g = [System.Drawing.Graphics]::FromImage($bmp) $rectSrc = New-Object System.Drawing.Rectangle(0, 0, $w, $cropH) $rectDst = New-Object System.Drawing.Rectangle(0, 0, $w, $cropH) $g.DrawImage($src, $rectDst, $rectSrc, [System.Drawing.GraphicsUnit]::Pixel) $bmp.Save('C:\Users\12914\Desktop\sky\hmr_live_top.png', [System.Drawing.Imaging.ImageFormat]::Png) $g.Dispose() $bmp.Dispose() $src.Dispose() Write-Output "cropped: ${w}x${cropH}"