A Powershell module for data URI to/from image file conversion, and data URI resizing.
Available in the Powershell Gallery
Convert an image file to a base64 data URI, create an image file from a base64 data URI, or resize a data URI as a new data URI.
Optionally resize the image prior to data URI conversion (original file retained, resizing is done in memory).
Install-Module ImageDataUriConverter
Import-Module ImageDataUriConverter
Invoke-ImageToDataUri
Invoke-DataUriToImage
Invoke-DataUriResize
Invoke-ImageToDataUri -File 'C:\Temp\an.image.png' -CopyToClipboard
'C:\Temp\an.image.png' | Invoke-ImageToDataUri -Width 30 -Height 30
Invoke-ImageToDataUri -File 'C:\Temp\an.image.png' -AsHtmlImgTag
Invoke-DataUriToImage -DataUri 'data:image/png;base64,iVBORw0K...'
Invoke-DataUriToImage -DataUri 'data:image/png;base64,iVBORw0K...' -OutFile 'C:\Temp\an.image.png'
Invoke-DataUriResize -DataUri 'data:image/png;base64,iVBORw0K...' -Width 30 -Height 30 -CopyToClipboard
dotnet build [Github clone/download directory]\ps-image-data-uri-converter\src\PsImageDataUriConverter.csproj
Remove any existing installation in this directory, create a new module directory and copy all the built files.
Remove-Item "C:\Users\[User]\Documents\PowerShell\Modules\ImageDataUriConverter" -Recurse -Force -ErrorAction SilentlyContinue
New-Item -Path 'C:\Users\[User]\Documents\PowerShell\Modules\ImageDataUriConverter' -ItemType Directory
Get-ChildItem -Path "[Github clone/download directory]\ps-image-data-uri-converter\src\PsImageDataUriConverterCmdlet\bin\Debug\net6.0\" | Copy-Item -Destination "C:\Users\[User]\Documents\PowerShell\Modules\ImageDataUriConverter" -Recurse
Please raise an issue if you find a bug or want to request a new feature, or create a pull request to contribute.