Last active
June 18, 2018 21:06
-
-
Save G33kDude/f4abad5f096992611e85 to your computer and use it in GitHub Desktop.
PngToBase64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FileSelectFile, File,,, Pick a PNG, Images (*.png) | |
Clipboard := PngToBase64(File) | |
MsgBox, % "The image is now on your clipboard. Paste into your browser URL bar." | |
return | |
PngToBase64(file) | |
{ | |
FileGetSize, size, % file | |
FileRead, bin, % "*c " file | |
return "data:image/png;base64," Base64enc(bin, size) | |
} | |
return | |
Base64enc(bin, size) | |
{ ; by SKAN | |
DllCall("Crypt32.dll\CryptBinaryToString" (A_IsUnicode ? "W" : "A"), UInt, &bin, UInt, size, UInt, 1, UInt, 0, UIntP, chars, "CDECL Int") | |
VarSetCapacity(out, req := chars * (A_IsUnicode ? 2 : 1 )) | |
DllCall("Crypt32.dll\CryptBinaryToString" (A_IsUnicode ? "W" : "A"), UInt, &bin, UInt, size, UInt, 1, Str, out, UIntP, req, "CDECL Int") | |
return out | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment