-
-
Save psrdotcom/ce1593f170fe931f9840b4a0f3eae89f to your computer and use it in GitHub Desktop.
HTML Convert an image to Base64 Image tag
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
@echo off | |
@setlocal enableextensions enabledelayedexpansion | |
SET resultFile="imageTag.html" | |
if [%1]==[] GOTO :Usage | |
REM Convert image to base64 string and remove header and footer cert | |
>NUL certutil -encode %1 tmp.b64 && findstr /v /c:- tmp.b64 > image_template_p2.txt && del tmp.b64 | |
@echo off | |
REM image_template_p1.txt contents are | |
REM <img src="data:image/png;base64, | |
type image_template_p1.txt > %resultFile% | |
type image_template_p2.txt >> %resultFile% | |
REM image_template_p3.txt contents are | |
REM " alt="PSR" /> | |
type image_template_p3.txt >> %resultFile% | |
ENDLOCAL | |
echo Image has been succesfully converted to Base64 support img tag. | |
exit /b | |
:Usage | |
echo Input a valid image file path as a parameter | |
echo Usage: Image2Base64.bat imageFile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment