Created
October 14, 2014 06:58
-
-
Save jamessantiago/a45400746b213161e3be to your computer and use it in GitHub Desktop.
Generate Background resolutions for windows lock screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[reflection.assembly]::LoadWithPartialName("System.Drawing") | Out-Null | |
#1920x1200 is the starting image, doesn't have to be this resolution | |
$baseImage = New-Object system.drawing.bitmap $pwd\1920x1200.jpg | |
$files = @" | |
Background1024x1280.jpg | |
Background1024x1280.jpg | |
Background1024x768.jpg | |
Background1280x1024.jpg | |
Background1280x768.jpg | |
Background1280x960.jpg | |
Background1360x768.jpg | |
Background1440x900.jpg | |
Background1600x1200.jpg | |
Background1920x1200.jpg | |
Background768x1280.jpg | |
Background768x1360.jpg | |
Background900x1440.jpg | |
Background960x1280.jpg | |
"@ | |
$files -split "`n" |% { | |
$res = $_ -replace "Background", "" -replace ".jpg", "" | |
$resolution = $res -split "x" | |
$w = [int]$resolution[0] | |
$h = [int]$resolution[1] | |
$w | |
$h | |
$newimage = New-Object System.Drawing.Bitmap $w, $h | |
$g = [System.Drawing.Graphics]::FromImage($newimage) | |
$g.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic | |
$g.DrawImage($baseImage, 0, 0, $w, $h) | |
"$pwd\$_" | |
$newimage.Save("$pwd\$_".trim(), ([System.Drawing.Imaging.ImageFormat]::Jpeg)) | |
$newimage.Dispose() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment