Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save marcostolosa/63509852dc75cab4042593b3bc57ece0 to your computer and use it in GitHub Desktop.

Select an option

Save marcostolosa/63509852dc75cab4042593b3bc57ece0 to your computer and use it in GitHub Desktop.
function Invoke-AIPromptStego {
param(
[string]$InFile,
[string]$OutFile,
[string]$OutFormat,
[string]$Prompt
)
Add-Type -AssemblyName System.Drawing
$bytes = [System.IO.File]::ReadAllBytes($InFile)
$bytes += [System.Text.Encoding]::UTF8.GetBytes([char[]]($Prompt))
$b64prompt = [System.Convert]::ToBase64String($bytes)
$binprompt = [System.Convert]::FromBase64String($b64prompt)
$stream = New-Object System.IO.MemoryStream($binprompt.Length)
$stream.Write($binprompt, 0, $binprompt.Length)
$stream.Position = 0
$img = [System.Drawing.Image]::FromStream($stream, $true, $false)
$img.Save($OutFile, [System.Drawing.Imaging.ImageFormat]::$OutFormat)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment