Combine Multiple Images into One (PowerShell + System.Drawing)

Stack all JPG files in a folder vertically into a single combined image using built-in .NET drawing.

Windowsimagessystem-drawingpowershellLow risk
Run the System.Drawing snippet in Windows PowerShell inside your image folder — it writes combined.jpg stacking every image top to bottom.

01Command

Command
$ Add-Type -AssemblyName System.Drawing
$files = Get-ChildItem "*.jpg" | Sort-Object Name
$imgs = $files | ForEach-Object { [System.Drawing.Image]::FromFile($_.FullName) }
$w = ($imgs | Measure-Object Width -Maximum).Maximum
$h = ($imgs | Measure-Object Height -Sum).Sum
$bmp = New-Object System.Drawing.Bitmap($w, $h)
$g = [System.Drawing.Graphics]::FromImage($bmp)
$y = 0
foreach ($i in $imgs) { $g.DrawImage($i, 0, $y, $i.Width, $i.Height); $y += $i.Height }
$bmp.Save("combined.jpg", [System.Drawing.Imaging.ImageFormat]::Jpeg)
$g.Dispose(); $bmp.Dispose()

02What it does

The script loads every JPG in the folder, computes a canvas big enough for the widest image and the total height, then draws each picture below the previous one. No extra software is needed because System.Drawing is part of Windows. To stack horizontally instead, swap the roles: set the canvas to total width / max height and advance x.

03Risk

RiskLow risk
RequirementsWindows PowerShell 5.1 (powershell.exe). Output combined.jpg is written next to the source images.
!Warning: Large photo sets can produce a gigantic canvas — memory use grows with total size, so batch very long merges.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Bitmap Class (System.Drawing)
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: Documents the System.Drawing Bitmap and Graphics classes used from PowerShell to create and draw a combined image.

Last verified: 2026-09-18 · Category: Media

06Related solutions