Skip to content

Instantly share code, notes, and snippets.

@WittmannJ
WittmannJ / ImgToBase64.ps1
Created December 18, 2018 17:25 — forked from colinMac/ImgToBase64.ps1
Powershell script to convert an image to base64 data uri format and store in a text file
Param([String]$path)
[bool]$valid = ($path -ne "")
if($valid) {
[String[]]$elements = $path.split(".")
[int]$max = $elements.Count -1
[String]$ext = $elements[$max]
[String]$uri = "data:image/$($ext);base64,"
$elements[$max] = "txt"
[String]$txtPath = $elements -join "."