Skip to content

Instantly share code, notes, and snippets.

View HaroldMitts's full-sized avatar
🎯
Focusing

Harold Mitts HaroldMitts

🎯
Focusing
View GitHub Profile
@HaroldMitts
HaroldMitts / base64myImage.ps1
Created March 4, 2024 05:05
This PowerShell script allows you to select an image file, converts it to a base64 string, and saves the string to a text file. It's useful for embedding images in text-based formats like HTML or CSS.
# Open a file dialog for the user to choose an image
Add-Type -AssemblyName System.Windows.Forms
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.ShowDialog() | Out-Null
$image_path = $OpenFileDialog.FileName
# Read the image file and convert it to a base64 string
$ImageBytes = [System.IO.File]::ReadAllBytes($image_path)
$Base64Image = [System.Convert]::ToBase64String($ImageBytes)