Bug 474338 - Base64 conversion for screenshot data
Summary: Base64 conversion for screenshot data
Status: CONFIRMED
Alias: None
Product: Spectacle
Classification: Applications
Component: General (show other bugs)
Version: 23.08.0
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Noah Davis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-09 13:39 UTC by Serg Podtynnyi
Modified: 2023-12-13 21:18 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
smime.p7s (2.42 KB, application/pkcs7-signature)
2023-09-09 15:06 UTC, Serg Podtynnyi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Serg Podtynnyi 2023-09-09 13:39:42 UTC
From https://invent.kde.org/graphics/spectacle/-/issues/7
```
I would like to suggest adding a button in the "Copy Image to Clipboard" dropdown which copies the base64 of the image to the Clipboard so that it can be easily pasted in things like markdown documents and such.
```
And add an option  in `After taking a screenshot` selection
* Copy image to clipboard (Base64)
Comment 1 Noah Davis 2023-09-09 14:32:09 UTC
Huh, I've never heard of that. Can you point me to some documentation about how this works? Is this only a feature for a specific flavor of Markdown?
Comment 2 Serg Podtynnyi 2023-09-09 15:06:11 UTC
Created attachment 161525 [details]
smime.p7s
Comment 3 Serg Podtynnyi 2023-09-09 21:23:17 UTC
The  format for data is here 
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs

and it looks like this:

in html:
<img src="data:image/png;base64,iVBORw0KGgoAAA
ANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4
//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU
5ErkJggg==" alt="Red dot" />

in markdown:
![Hello World](data:image/png;base64,iVBORw0KGgoAAA
ANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4
//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU
5ErkJggg==)

so clipboard should have string data starting with data:image/png;base64, 
and ends with(out)  base64  paddings ==

PS
For QT it is something like this https://doc.qt.io/qt-6/qbytearray.html#toBase64
Comment 4 Noah Davis 2023-09-10 22:10:31 UTC
Doesn't seem like a high priority and it's a pretty advanced user option, but I'll leave this report open.
Comment 5 Noah Davis 2023-09-10 22:19:08 UTC
You might actually want to look into customizing Klipper (the clipboard applet) actions. You can make Klipper run commands on things you copied to the clipboard and there may be a way to convert images in the clipboard to base64.