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.
01Command
$ 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
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- Bitmap Class (System.Drawing)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
Search inside text files and logs with regex, returning file, line number and match.
Create or update a .zip from any files or folder contents straight from PowerShell.
A built-in PowerShell one-liner that answers 'is port 5432/3389/443 actually open through this network?' — no telnet client needed.