StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
Scripts to convert clipboard image to HTML code (Base64)
Rank: Member
Groups: Approved
Joined: 11/22/2020(UTC) Posts: 7 Was thanked: 7 time(s) in 2 post(s)
|
The first script is to convert clipboard image to Base64 string, and then output HTML code to clipboard. Code:if (clip.ContainsImage()) {
var clipboardImage = clip.GetImage();
var ms = new clr.System.IO.MemoryStream();
clipboardImage.Save(ms, drawing.System.Drawing.Imaging.ImageFormat.Png);
ms.Position = 0;
var base64Img = clr.System.Convert.ToBase64String(ms.GetBuffer());
var imgHTML = "<img alt='Clipped Image' src='" + "data:image/png;base64," + base64Img + "' />";
clip.SetText(imgHTML);
ms.Close();
}
The second script is to get svg file path from clipboard, read it, convert it to Base64 string and output HTML code to clipboard. Code:if (clip.ContainsFileDropList()) {
var clipFileList = clip.GetFileDropList();
if (clipFileList[0].includes(".svg")) {
var svgFilePath = clipFileList[0];
var base64Img = clr.System.Convert.ToBase64String(clr.System.IO.File.ReadAllBytes(svgFilePath));
var imgHTML = "<img alt='Clipped Image' src='" + "data:image/svg+xml;base64," + base64Img + "' />";
clip.SetText(imgHTML);
}
}
|
3 users thanked Jack Ma for this useful post.
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 10/26/2020(UTC) Posts: 50 Location: Darmstadt Thanks: 15 times Was thanked: 2 time(s) in 2 post(s)
|
Thanks Jack Ma, this could come in quite handy one time! Immediately saved it to my macros...
|
|
|
|
StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
Scripts to convert clipboard image to HTML code (Base64)
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close