-
What would be the best way to convert an image in the clipboard to a base64 string?
But I'm a bit unsure on how to proceed, particularly the getting the image to an external script. Can anyone help me figure this out? SolutionCalling external script[Command]
Command="
copyq:
var img = data(\"image/png\")
var pth = Dir().homePath() + \"/.local/share/scripts/img2base64.sh\"
var cmd = execute(pth, null, img)
if (cmd && cmd.exit_code == 0) {
var result=str(cmd.stdout)
tab('clipboard')
add(result)
copy(result)
}"
Icon=\xf03e
InMenu=true
Input=image/png
Name=Base64 Pure copyq[Command]
Command="
copyq:
var img = data(\"image/png\")
var result = \"data:image/png;base64,\" + toBase64(img)
tab('clipboard')
add(result)
copy(result)"
Enable=false
Icon=\xf03e
InMenu=true
Input=image/png
Name=Base64 Can probably be optimized, but does the job. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
There is already a function to convert to base 64 "toBase64()" To paste result:
|
Beta Was this translation helpful? Give feedback.
-
You said it is in the clipboard, read the clipboard to get the data (click F4 on item to see the available formats and their values). |
Beta Was this translation helpful? Give feedback.
You said it is in the clipboard, read the clipboard to get the data (click F4 on item to see the available formats and their values).