Skip to content

Commit

Permalink
Fallback to System.Drawing.Bitmap if PNG isn't available (b-init#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
teetow authored Sep 21, 2022
1 parent 03d4a8b commit 5380700
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions imagepaste/clipboard/windows/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def push(cls, save_directory: str) -> WindowsClipboard:
"Add-Type -AssemblyName System.Drawing; "
"$clipboard = [System.Windows.Forms.Clipboard]::GetDataObject(); "
"$imageStream = $clipboard.GetData('PNG'); "
"if ($null -eq $imageStream) { $imageStream = $clipboard.GetData('image/png') }; "
"if ($null -eq $imageStream) { $imageStream = $clipboard.GetData('System.Drawing.Bitmap') }; "
"if ($imageStream) {"
"$bitmap = New-Object System.Drawing.Bitmap($imageStream); "
f"$bitmap.Save('{filepath}', [System.Drawing.Imaging.ImageFormat]::Png); "
Expand Down

0 comments on commit 5380700

Please sign in to comment.