Skip to content

Instantly share code, notes, and snippets.

Created May 13, 2011 02:20
  • Star 24 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Display an image from Windows Powershell
# Loosely based on
$file = (get-item 'C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg')
#$file = (get-item "c:\image.jpg")
$img = [System.Drawing.Image]::Fromfile($file);
# This tip from
$form = new-object Windows.Forms.Form
$form.Text = "Image Viewer"
$form.Width = $img.Size.Width;
$form.Height = $img.Size.Height;
$pictureBox = new-object Windows.Forms.PictureBox
$pictureBox.Width = $img.Size.Width;
$pictureBox.Height = $img.Size.Height;
$pictureBox.Image = $img;
$form.Add_Shown( { $form.Activate() } )
Copy link

Created 11 years ago but useful to me this morning! Thanks people.

Copy link

Great to hear @jacquesfrancis

Copy link

Thanks for this. Just used it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment