Maybe this is common knowledge. For most cases whenever I needed a base64 version of an image to use in a webpage, I used one of those online sites to get it.
Recently on a client project I wasn't sure if I wanted to upload their images on an unknown site. So I did a quick Google (fine, stackoverflow) and found that we can just run this on most Linux style systems.
cat image-file.jpg | base64
Also works on macOS and for other image types