I have a project where I want to embed an PNG image into a Tampermonkey script.
Lucky for me, Firefox is capable of converting an image file on disk into a base64 dataurl!
All I had to do is right click on the file I wanted to convert, and open it in Firefox. After that, right click on the image and select inspect element.
In the HTML inspector, right click on the src of the img tag, then click Copy > Image Data URL.
Firefox will put the base64 Data URL data on the clipboard, which can be pasted into your code editor.