Powershell GUI encode decode images

Recently I was working on the one of my project, In the same I required to add few images to GUI, and needed to encode and decode images in the script so no external file is required to port incase if I want to share and there will be only sole ps1 script. Here in below video not a single external picture image is used. They are for onetime encoded with powershell as base64 string and then same string is used to decode in the script.

Powershell wpf winform file, encode decode bitmapimage, follow image control

Here I have download all the required images from internet as shown in below screenshot and showing demo for one image only, for other images need you can follow same procedure to convert encode image. With below one-liner command I encoded image to base64 string, yellow highlighted text is the image file path. Converted string is directly copied to clipboard.

[convert]::ToBase64String((get-content 'C:TempIconstwitter.png' -encoding byte)) | Out-Clipboard

More information on convert to base64 string, check this link

Microsoft powershell wpf winforms, encode decode images from base64 string using bitmapimage .net from io memory

Copied string is pasted in side script as below.

$TwitterImg = @'
iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABvVJREFUeNrsW2tsU2UYfnp6b7e13Vq6rWUbA7ltkyGgMAPi5KagokhiJE4QNPxZokYxqInGGGNijPoDEgwxWVASAYcjOogEA8uUrQJBNsbFsQu7X7t2XbuuPa3fdyqEuQu9nF5i+yZft2znnJ73Oe/led6vFSw80nIIQD5Zo4gvk5FVLyIvRWTlIj4thSEvPYhf66EACOIYAAGDOLcEAAkAEgAkAEgAkAAgAUACgAQAsWwKkQCzkoTxBcA6owJFylF8tlSDqqeNeEhoxvp0IV7MTQKfUIhi0fld81UozVPBxaZCLhbC7BjDR2vzwQgEaLM4cLzuNlhl6v8TgB3zUvBmgdp3c4zvWbs9Xhyvb8dvt3q5BV0Wb6Eb1HX08vDk48p0Od4q0Iz7m5css30MBpUCSwwaLM5Qw93fCdY2RP7pDV0PLzzScp78XB7ISRXrM2Ed86C82YZT7SNwuEO/EbWEwc8bDNBI7/9MGnqt+OTMVZi6bBDrDGBkymDftkao2/rGLvKLMZCzMpUibMxSotigwLYHkmFQitHlYDEwygYNwIdL0lCYJvXrWJ1Sii0FMyEjWFXX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LnXY3KjcYsJ30dDoBnlZbC3x7ej+ty0BpvjqshZDy+1d+qOW2zUKx+xKhr+qGuHn9O4s0nFOU8Zn6RtE67IbVxUJONLiRVH16zGqSMtoIiKGe4VFsP1qLVvNIyNfySwylSoX4rjgd2UnR30q80TeMnYTudlkdfFzOPzE06GSx42w3moddUXWebpC+cKiaL+cDa4N06ltyphOmdnNUZG1pxUW8/ctl2F0sr9cOqEQPkgDY+bsZ+00t91VbfBjddCm72Iw135xF5fWusLxHwEntYYTY18ziZONFvPdoDlZka8PC7I7VteFAzS108hjuvADgixshmgRpKKmox1KtBK8uy/WNpAWh9b26bgvK69tw4moHhkYjU2+CL+sCBpL0HFzovQ1T+QVu9rZ2bjpW5uhQaNDAkDI9i6TkpdVsx5XuIdTeHkBVcx+vxY3XNji9DvXC1d8Bdnh8cUySipClVkKrkEAqEkJCSNSY24Nhpwu9Nic6rHY43Z5od9XQx+J0l0OsM3IRcWfMRM3mdKOhx4JYN96IulibOdnGQ/wAwBUUuvvyn42HuAKAA4FEgSgtM34B4EBQpfnqQrwCwEnjZA3E+izfVnA8AsCBoFRBos+O6W/nhf3O6Ce3KGECI4xZAMKuahi5EpKMmATBSwHQRwRpqQLSzFySFzH1+Ww9vZs/yLIiAl+fF0hkBITZcHY2Aawr2s5zX5//R4ABAMlGU7MRbcgUAAAAAElFTkSuQmCC
'@

With below function you can decode this string and convert to System.Windows.Media.Imaging.BitmapImage and save the object in memory. This information then can easily re-purposed as image source.

   1   2   3   4   5   6   7   8   9  10  11  12  13
  function DecodeBase64Image {      param (          [Parameter(Mandatory=$true)]          [String]$ImageBase64      )      # Parameter help description      $ObjBitmapImage = New-Object System.Windows.Media.Imaging.BitmapImage #Provides a specialized BitmapSource that is optimized for loading images using Extensible Application Markup Language (XAML).      $ObjBitmapImage.BeginInit() #Signals the start of the BitmapImage initialization.      $ObjBitmapImage.StreamSource = [System.IO.MemoryStream][System.Convert]::FromBase64String($ImageBase64) #Creates a stream whose backing store is memory.      $ObjBitmapImage.EndInit() #Signals the end of the BitmapImage initialization.      $ObjBitmapImage.Freeze() #Makes the current object unmodifiable and sets its IsFrozen property to true.      $ObjBitmapImage  }  
In the XAML I have used Image control.

To show the images, I am using earlier function to convert from string, The object is actually in a .net object format and is in the memory.
$Twitter.Source = DecodeBase64Image -ImageBase64 $TwitterImg

Copy below script from this link, it is also available on Github.com.

    1    2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99  100  101  102  103  104  105  106  107  108  109  110  111  112  113  114  115  116
        .NOTES       --------------------------------------------------------------------------------        Code generated using by: Visual Studio        Created on:              4/17/2018 4:57 AM        Get Help on:             http://vcloud-lab.com        Written by:              Kunal Udapi        Build & Tested on:       Windows 10        Purpose:                 This script encode and decode images in powershell gui, so no Image picture file need to attach separately.     --------------------------------------------------------------------------------       .DESCRIPTION         GUI script generated using Visual Studio 2017     #>      $TitleIcon = @'   iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAADiklEQVR42r1WaUhUURQ+11mqochxK1t/FCpSpNliqWnojyZyJFBTLCJITbAMRUnCZswimVIqBMv6UbSJFuVCFo2kjZYtloKISf0oCsslDUvJGb2de503Pp8zSZBduJxz1++c75x37iPwh6bdne6LIpYQEk4p9UWpRsmW+rG347gWx2WV1wvbHd1BHFzsg4cNeFiDQxnqBHUqSNvh8bEF1RpUsyquFXRMCxC1JyMZRSF2FfxdG8KejiAXHQLg5bloUY7IOiroKOhiTw8uP3d1A1uS7rHqeUiZbgoA0pKMe4oFBqSHF3q40qL8LA6QesQAXV97HQEwPUXwhFgt90HRLKbFzcWZy95vA1zGaCMgIXob12/cfgDllUa7+0R0BbCYEKv1lSh2CFa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4tu1AqddfonzaXn8UML3g+QPf0gHfEu9rzzJ+Dc3N1+U6e1RoDIZvEpOS1Aw9+MST9xXRuz7YBsoZErAOuY4fNiV1dR2ZyFLfxeZmTuU7ahQTRzP8YKwfBi8DF9AncwdXCsvL220fhITuLE5qARvyPPMedw8P4zAfn7IxAQHFeKflS7uSUkkpXLVmjWrdpk1aa5atWiXg5FVSbuFkibu7O7PY7/A8HmB1IAdsBYvAL0CvLy33s0jKnrXjTItnzp5NfeYy8vMIP68EghlgPuAD+fnkHbAZ8DNIJuDsSXwK/gr4ySURMBzCwGjwP2P6QSx27LhxPzpEgkNCmH/nAk+xxc/cFo1CRik5f+zUqRZc45eAx8XafmBjeA5Icolki6feibtV/cdy+S2GA0BOwk+ABXcv9x/zA22r3n5bladW802MqTTVqV8ZlaYaiqRnfo7/VBV/VvQncwYxIB/wEwnlz252s5vd7Ga3n5kNGPBfD1/zlDz7hBsAAAAASUVORK5CYII=  '@    #Load required libraries   Add-Type -AssemblyName PresentationFramework, PresentationCore, WindowsBase, System.Windows.Forms, System.Drawing    function DecodeBase64Image {      param (          [Parameter(Mandatory=$true)]          [String]$ImageBase64      )      # Parameter help description      $ObjBitmapImage = New-Object System.Windows.Media.Imaging.BitmapImage #Provides a specialized BitmapSource that is optimized for loading images using Extensible Application Markup Language (XAML).      $ObjBitmapImage.BeginInit() #Signals the start of the BitmapImage initialization.      $ObjBitmapImage.StreamSource = [System.IO.MemoryStream][System.Convert]::FromBase64String($ImageBase64) #Creates a stream whose backing store is memory.      $ObjBitmapImage.EndInit() #Signals the end of the BitmapImage initialization.      $ObjBitmapImage.Freeze() #Makes the current object unmodifiable and sets its IsFrozen property to true.      $ObjBitmapImage  }    [xml]$xaml = @"             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"          xmlns:local="clr-namespace:WpfApp8"            Title="Image Demo" Height="200" Width="398" SizeToContent="Width" ResizeMode='NoResize' WindowStartupLocation="CenterScreen">                                                                                                                                                                                                            "@     #Read the form   $Reader = (New-Object System.Xml.XmlNodeReader $xaml)    $Form = [Windows.Markup.XamlReader]::Load($reader)      #AutoFind all controls   $xaml.SelectNodes("//*[@*[contains(translate(name(.),'n','N'),'Name')]]")  | ForEach-Object {        New-Variable  -Name $_.Name -Value $Form.FindName($_.Name) -Force    }    #$ImageBase64 = [convert]::ToBase64String((get-content C:TempIconsfollow.png -encoding byte)) | Out-Clipboard    $Form.Icon = DecodeBase64Image -ImageBase64 $TitleIcon  $Twitter.Source = DecodeBase64Image -ImageBase64 $TwitterImg  $Facebook.Source = DecodeBase64Image -ImageBase64 $FacebookImg  $GooglePlus.Source = DecodeBase64Image -ImageBase64 $GooglePlusImg  $Youtube.Source = DecodeBase64Image -ImageBase64 $YoutubeImg  $Linkedin.Source = DecodeBase64Image -ImageBase64 $LinkedinImg  $FollowMe.Source = DecodeBase64Image -ImageBase64 $FollowMeImg    $Twitter.Add_MouseEnter({$Label.Text = 'Follow me on Twitter'; $Script:url = 'https://twitter.com/kunaludapi'})  $Facebook.Add_MouseEnter({$Label.Text = 'Follow me on Facebook'; $Script:url = 'https://www.facebook.com/kunaludapi.outlook'})  $GooglePlus.Add_MouseEnter({$Label.Text = 'Follow me on Google+'; $Script:url = 'https://plus.google.com/+kunaludapi'})  $Youtube.Add_MouseEnter({$Label.Text =  'Follow me on Youtube'; $Script:url = 'https://www.youtube.com/kunaludapi'})  $Linkedin.Add_MouseEnter({$Label.Text = 'Follow me on Linkedin'; $Script:url = 'https://www.linkedin.com/in/kunaludapi/'})    $Label.Add_PreviewMouseDown({[system.Diagnostics.Process]::start($url)})    #Mandetory last line of every script to load form   [void]$Form.ShowDialog()   

Useful Articles
Powershell WPF Charts dashboard demo
Part 1: Create WPF XAML powershell GUI form with Visual studio
Part 2: Powershell and WPF: Build GUI applications tutorial
Part 3: Create shorter Microsoft Powershell WPF automated clean script
Powershell PoshGUI: Convert user to SID and vice versa using
Microsoft Powershell GUI: Change Internet Options connections Lan settings proxy server grayed out



via Latest imported feed items on VMware Blogs https://ift.tt/2IpWnO3
RSS Feed

If New feed item from https://blogs.vmware.com/feed, then send me an email at kr

IFTTT

Comments

Popular posts from this blog

Evernote cuts staff as user growth stalls

The best air conditioner

We won't see a 'universal' vape oil cartridge anytime soon