-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshrink.ps1
More file actions
19 lines (17 loc) · 829 Bytes
/
Copy pathshrink.ps1
File metadata and controls
19 lines (17 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Add-Type -AssemblyName System.Windows.Forms
[void][Reflection.Assembly]::LoadWithPartialName(“System.Drawing”)
$cbImage = [System.Windows.Forms.Clipboard]::GetImage()
If ($cbImage -ne $null)
{
$ratio = 71 # Shriink/Expand ratio: This setting shrink the original image to 71%.
$ratio = $ratio / 100
$newWidth = [int]($cbImage.Width * $ratio) # Change this setting
$newHeight = [int]($cbImage.Height * $ratio) # if you change the aspect ratio
$bmImage = New-Object System.Drawing.Bitmap($newWidth, $newHeight)
$newImage = [System.Drawing.Graphics]::FromImage($bmImage)
$newImage.DrawImage($cbImage, $(New-Object -TypeName System.Drawing.Rectangle -ArgumentList 0, 0, $newWidth, $newHeight))
[Windows.Forms.Clipboard]::SetImage($bmImage)
$cbImage.Dispose()
$bmImage.Dispose()
$newImage.Dispose()
}